Only use TIOCNOTTY in the non-setsid case. If no TIOCSCTTY, just
reopen slave.
This commit is contained in:
16
script.c
16
script.c
@@ -463,7 +463,11 @@ script_child(path, argv)
|
|||||||
* and the slave pty as the controlling terminal.
|
* and the slave pty as the controlling terminal.
|
||||||
* This allows us to be notified when the child has been suspended.
|
* This allows us to be notified when the child has been suspended.
|
||||||
*/
|
*/
|
||||||
#ifdef TIOCNOTTY
|
#ifdef HAVE_SETSID
|
||||||
|
if (setsid() == -1)
|
||||||
|
log_error(USE_ERRNO, "setsid");
|
||||||
|
#else
|
||||||
|
# ifdef TIOCNOTTY
|
||||||
n = open(_PATH_TTY, O_RDWR|O_NOCTTY);
|
n = open(_PATH_TTY, O_RDWR|O_NOCTTY);
|
||||||
if (n >= 0) {
|
if (n >= 0) {
|
||||||
/* Disconnect from old controlling tty. */
|
/* Disconnect from old controlling tty. */
|
||||||
@@ -471,16 +475,16 @@ script_child(path, argv)
|
|||||||
warning("cannot disconnect controlling tty");
|
warning("cannot disconnect controlling tty");
|
||||||
close(n);
|
close(n);
|
||||||
}
|
}
|
||||||
#endif
|
# endif
|
||||||
#ifdef HAVE_SETSID
|
|
||||||
if (setsid() == -1)
|
|
||||||
log_error(USE_ERRNO, "setsid");
|
|
||||||
#else
|
|
||||||
setpgrp(0, 0);
|
setpgrp(0, 0);
|
||||||
#endif
|
#endif
|
||||||
#ifdef TIOCSCTTY
|
#ifdef TIOCSCTTY
|
||||||
if (ioctl(script_fds[SFD_SLAVE], TIOCSCTTY, NULL) != 0)
|
if (ioctl(script_fds[SFD_SLAVE], TIOCSCTTY, NULL) != 0)
|
||||||
log_error(USE_ERRNO, "unable to set controlling tty");
|
log_error(USE_ERRNO, "unable to set controlling tty");
|
||||||
|
#else
|
||||||
|
/* Set controlling tty by reopening slave. */
|
||||||
|
if ((n = open(slavename, O_RDWR)) >= 0)
|
||||||
|
close(n);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ((idfile = fdopen(script_fds[SFD_LOG], "w")) == NULL)
|
if ((idfile = fdopen(script_fds[SFD_LOG], "w")) == NULL)
|
||||||
|
Reference in New Issue
Block a user