1
0
mirror of https://github.com/Interlisp/maiko.git synced 2026-01-14 23:46:14 +00:00

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.
This commit is contained in:
Bruce Mitchener 2021-01-01 00:44:36 +07:00 committed by GitHub
parent d28334bd24
commit ca3f27db1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -99,20 +99,8 @@ int ForkUnixShell(int slot, char ltr, char numb, char *termtype, char *shellarg)
char envstring[64];
char *argvec[4];
#ifndef SYSVONLY
/* Divorce ourselves from /dev/tty */
res = open("/dev/tty", O_RDWR);
if (res >= 0) {
(void)ioctl(res, TIOCNOTTY, (char *)0);
(void)close(res);
} else {
perror("Slave TTY");
exit(0);
}
#else
if (0 > setsid()) /* create us a new session for tty purposes */
perror("setsid");
#endif
if (0 > setsid()) /* create us a new session for tty purposes */
perror("setsid");
/* Open the slave side */
#ifndef FULLSLAVENAME