14 /* Initialize tty_fd. Used for saving/reseting tty modes upon
15 * foreground job completion and for setting up tty process group.
18 tty_init(int init_ttystate
)
30 if ((tfd
= open("CONSOLE:", O_RDWR
, 0)) < 0) {
32 if ((tfd
= open("/dev/tty", O_RDWR
, 0)) < 0) {
35 warningf(false, "No controlling tty (open /dev/tty: %s)",
46 warningf(false, "Can't find tty file descriptor");
50 if ((tty_fd
= fcntl(tfd
, F_DUPFD
, FDBASE
)) < 0) {
51 warningf(false, "j_ttyinit: dup of tty fd failed: %s",
54 } else if (fcntl(tty_fd
, F_SETFD
, FD_CLOEXEC
) < 0) {
55 warningf(false, "j_ttyinit: can't set close-on-exec flag: %s",
60 } else if (init_ttystate
)
61 //tcgetattr(tty_fd, &tty_state);