diff options
author | Jérémie Courrèges-Anglas <jca@wxcvbn.org> | 2014-02-20 14:04:58 +0100 |
---|---|---|
committer | Jérémie Courrèges-Anglas <jca@wxcvbn.org> | 2014-02-20 14:04:58 +0100 |
commit | 3cee18b208f1c8e3147b13148130ba12a7dcf6e2 (patch) | |
tree | a2a2b1cdbe345866b1c008437c405d712bfd6de5 | |
parent | e88fc334835a4669d1dd27f7156ceb720a3eafb0 (diff) | |
download | ratpoison-3cee18b208f1c8e3147b13148130ba12a7dcf6e2.zip |
Fall back to ioctl(TIOCNOTTY) to detach from the controlling terminal.
* As with setpgid, only do this if setsid fails or is absent.
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | src/actions.c | 15 |
2 files changed, 16 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac index cf84ef1..8e749b5 100644 --- a/configure.ac +++ b/configure.ac @@ -165,7 +165,7 @@ AS_IF([test "$with_electric_fence" = yes], dnl Checks for header files. AC_HEADER_STDC -AC_CHECK_HEADERS([pwd.h]) +AC_CHECK_HEADERS([pwd.h sys/ioctl.h]) dnl Checks for typedefs, structures, and compiler characteristics. AC_C_TYPEOF diff --git a/src/actions.c b/src/actions.c index 79db068..8917b85 100644 --- a/src/actions.c +++ b/src/actions.c @@ -34,6 +34,10 @@ #ifdef HAVE_LIBXTST # include <X11/extensions/XTest.h> #endif + +#ifdef HAVE_SYS_IOCTL_H +# include <sys/ioctl.h> +#endif #define ARG_STRING(elt) args[elt]->string @@ -2649,6 +2653,17 @@ spawn(char *cmd, int raw, rp_frame *frame) if (setsid() == -1) #endif { +#if defined (HAVE_SYS_IOCTL_H) && defined (TIOCNOTTY) + int ctty; + + ctty = open ("/dev/tty", O_RDONLY); + if (ctty != -1) + { + ioctl (ctty, TIOCNOTTY); + close (ctty); + } +#endif + #if defined (HAVE_SETPGID) setpgid (0, 0); #elif defined (HAVE_SETPGRP) |