From 5010c3b657c9497ce3e948324b487f1933bcf6eb Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Thu, 8 Jun 2006 14:04:36 +0000 Subject: [PATCH] Reparent the process that executes the window= command from the ttys to the init. This prevents zombies from being accumulated. PR: bin/64198 Tested by: Eugene Grosbein Approved by: kan (mentor) MFC after: 1 month --- sbin/init/init.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/sbin/init/init.c b/sbin/init/init.c index 393955f0abde..eb0569a17641 100644 --- a/sbin/init/init.c +++ b/sbin/init/init.c @@ -1066,6 +1066,7 @@ start_window_system(session_t *sp) pid_t pid; sigset_t mask; char term[64], *env[2]; + int status; if ((pid = fork()) == -1) { emergency("can't fork for window system on port %s: %m", @@ -1073,9 +1074,20 @@ start_window_system(session_t *sp) /* hope that getty fails and we can try again */ return; } - if (pid) + { + waitpid(-1, &status, 0); return; + } + + /* reparent window process to the init to not make a zombie on exit */ + if ((pid = fork()) == -1) { + emergency("can't fork for window system on port %s: %m", + sp->se_device); + _exit(1); + } + if (pid) + _exit(0); sigemptyset(&mask); sigprocmask(SIG_SETMASK, &mask, (sigset_t *) 0);