From: Rich Felker Date: Thu, 21 Apr 2011 01:01:42 +0000 (-0400) Subject: properly create new session/controlling terminal in forkpty X-Git-Tag: v0.7.9~9 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=10d7561db5d51231939fa0b42d17eaac2bff6938;p=oweals%2Fmusl.git properly create new session/controlling terminal in forkpty --- diff --git a/src/misc/forkpty.c b/src/misc/forkpty.c index 2d1b0ae2..0bbf2de2 100644 --- a/src/misc/forkpty.c +++ b/src/misc/forkpty.c @@ -1,5 +1,6 @@ #include #include +#include int forkpty(int *m, char *name, const struct termios *tio, const struct winsize *ws) { @@ -10,10 +11,12 @@ int forkpty(int *m, char *name, const struct termios *tio, const struct winsize pid = fork(); if (!pid) { close(*m); + setsid(); + ioctl(s, TIOCSCTTY, (char *)0); dup2(s, 0); dup2(s, 1); dup2(s, 2); - close(s); + if (s>2) close(s); return 0; } close(s);