Skip to content

Commit ca3f27d

Browse files
Use setsid on all Unix platforms. (#152)
Previously, we used `TIOCNOTTY` on some platforms (FreeBSD, macOS) and `setsid` on Linux and Solaris. The correct modern way to do this is to use `setsid` and the BSDs support this, so let's just do that.
1 parent d28334b commit ca3f27d

File tree

1 file changed

+2
-14
lines changed

1 file changed

+2
-14
lines changed

src/unixfork.c

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -99,20 +99,8 @@ int ForkUnixShell(int slot, char ltr, char numb, char *termtype, char *shellarg)
9999
char envstring[64];
100100
char *argvec[4];
101101

102-
#ifndef SYSVONLY
103-
/* Divorce ourselves from /dev/tty */
104-
res = open("/dev/tty", O_RDWR);
105-
if (res >= 0) {
106-
(void)ioctl(res, TIOCNOTTY, (char *)0);
107-
(void)close(res);
108-
} else {
109-
perror("Slave TTY");
110-
exit(0);
111-
}
112-
#else
113-
if (0 > setsid()) /* create us a new session for tty purposes */
114-
perror("setsid");
115-
#endif
102+
if (0 > setsid()) /* create us a new session for tty purposes */
103+
perror("setsid");
116104

117105
/* Open the slave side */
118106
#ifndef FULLSLAVENAME

0 commit comments

Comments
 (0)