diff options
Diffstat (limited to 'networking/telnetd.c')
-rw-r--r-- | networking/telnetd.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/networking/telnetd.c b/networking/telnetd.c index 51bd0c012..25cba3eb0 100644 --- a/networking/telnetd.c +++ b/networking/telnetd.c | |||
@@ -283,15 +283,19 @@ make_new_session( | |||
283 | 283 | ||
284 | /* child */ | 284 | /* child */ |
285 | 285 | ||
286 | /* make new process group */ | ||
287 | setsid(); | ||
288 | tcsetpgrp(0, getpid()); | ||
289 | /* ^^^ strace says: "ioctl(0, TIOCSPGRP, [pid]) = -1 ENOTTY" -- ??! */ | ||
290 | |||
286 | /* open the child's side of the tty. */ | 291 | /* open the child's side of the tty. */ |
287 | fd = xopen(tty_name, O_RDWR /*| O_NOCTTY*/); | 292 | /* NB: setsid() disconnects from any previous ctty's. Therefore |
293 | * we must open child's side of the tty AFTER setsid! */ | ||
294 | fd = xopen(tty_name, O_RDWR); /* becomes our ctty */ | ||
288 | dup2(fd, 0); | 295 | dup2(fd, 0); |
289 | dup2(fd, 1); | 296 | dup2(fd, 1); |
290 | dup2(fd, 2); | 297 | dup2(fd, 2); |
291 | while (fd > 2) close(fd--); | 298 | while (fd > 2) close(fd--); |
292 | /* make new process group */ | ||
293 | setsid(); | ||
294 | tcsetpgrp(0, getpid()); | ||
295 | 299 | ||
296 | /* The pseudo-terminal allocated to the client is configured to operate in | 300 | /* The pseudo-terminal allocated to the client is configured to operate in |
297 | * cooked mode, and with XTABS CRMOD enabled (see tty(4)). */ | 301 | * cooked mode, and with XTABS CRMOD enabled (see tty(4)). */ |