aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2002-10-12 04:05:48 +0000
committerEric Andersen <andersen@codepoet.org>2002-10-12 04:05:48 +0000
commite8a90fb2bcdd09159455fcafc94428e31cbe9670 (patch)
tree560843b486aaee0d308cf58cf53ef23ed6bba5ad
parent71ae64bdc6b044eef0a9f3bebd85cc4a6b67362f (diff)
downloadbusybox-w32-e8a90fb2bcdd09159455fcafc94428e31cbe9670.tar.gz
busybox-w32-e8a90fb2bcdd09159455fcafc94428e31cbe9670.tar.bz2
busybox-w32-e8a90fb2bcdd09159455fcafc94428e31cbe9670.zip
After thinking about it, I think this patch from Matt Kraai is probably the
best way to go. Sysvinit does not provide a controlling tty since it doesn't even try to open ttys for apps. We do. So we should _try_ to provide a controlling tty if possible, but we needn't freak out if it doesn't work. This way we won't need to use openvt or similar, we'll just have init do the Right Thing(tm).
-rw-r--r--init/init.c16
1 files changed, 3 insertions, 13 deletions
diff --git a/init/init.c b/init/init.c
index edbd90bfe..ec1bacc83 100644
--- a/init/init.c
+++ b/init/init.c
@@ -501,12 +501,11 @@ static pid_t run(struct init_action *a)
501 signal(SIGTSTP, SIG_DFL); 501 signal(SIGTSTP, SIG_DFL);
502 502
503 /* Create a new session and make ourself the process 503 /* Create a new session and make ourself the process
504 * group leader for non-interactive jobs */ 504 * group leader */
505 if ((a->action & (RESPAWN)) == 0) 505 setsid();
506 setsid();
507 506
508 /* Open the new terminal device */ 507 /* Open the new terminal device */
509 if ((device_open(a->terminal, O_RDWR | O_NOCTTY)) < 0) { 508 if ((device_open(a->terminal, O_RDWR)) < 0) {
510 if (stat(a->terminal, &sb) != 0) { 509 if (stat(a->terminal, &sb) != 0) {
511 message(LOG | CONSOLE, "\rdevice '%s' does not exist.\n", 510 message(LOG | CONSOLE, "\rdevice '%s' does not exist.\n",
512 a->terminal); 511 a->terminal);
@@ -516,10 +515,6 @@ static pid_t run(struct init_action *a)
516 _exit(1); 515 _exit(1);
517 } 516 }
518 517
519 /* Non-interactive jobs should not get a controling tty */
520 if ((a->action & (RESPAWN)) == 0)
521 (void) ioctl(0, TIOCSCTTY, 0);
522
523 /* Make sure the terminal will act fairly normal for us */ 518 /* Make sure the terminal will act fairly normal for us */
524 set_term(0); 519 set_term(0);
525 /* Setup stdout, stderr for the new process so 520 /* Setup stdout, stderr for the new process so
@@ -527,11 +522,6 @@ static pid_t run(struct init_action *a)
527 dup(0); 522 dup(0);
528 dup(0); 523 dup(0);
529 524
530 /* For interactive jobs, create a new session
531 * and become the process group leader */
532 if ((a->action & (RESPAWN)))
533 setsid();
534
535 /* If the init Action requires us to wait, then force the 525 /* If the init Action requires us to wait, then force the
536 * supplied terminal to be the controlling tty. */ 526 * supplied terminal to be the controlling tty. */
537 if (a->action & (SYSINIT | WAIT | CTRLALTDEL | SHUTDOWN | RESTART)) { 527 if (a->action & (SYSINIT | WAIT | CTRLALTDEL | SHUTDOWN | RESTART)) {