From eugen@www.svzserv.kemerovo.su Fri Mar 12 23:31:00 2004 Return-Path: Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5230116A4CE for ; Fri, 12 Mar 2004 23:31:00 -0800 (PST) Received: from www.svzserv.kemerovo.su (www.svzserv.kemerovo.su [213.184.65.80]) by mx1.FreeBSD.org (Postfix) with ESMTP id 69A7B43D2D for ; Fri, 12 Mar 2004 23:30:59 -0800 (PST) (envelope-from eugen@www.svzserv.kemerovo.su) Received: from www.svzserv.kemerovo.su (smmsp@localhost [127.0.0.1]) by www.svzserv.kemerovo.su (8.12.11/8.12.11) with ESMTP id i2D7UurS025137 for ; Sat, 13 Mar 2004 14:30:56 +0700 (KRAT) (envelope-from eugen@www.svzserv.kemerovo.su) Received: (from eugen@localhost) by www.svzserv.kemerovo.su (8.12.11/8.12.11/Submit) id i2D7CTtK017745; Sat, 13 Mar 2004 14:12:29 +0700 (KRAT) (envelope-from eugen) Message-Id: <200403130712.i2D7CTtK017745@www.svzserv.kemerovo.su> Date: Sat, 13 Mar 2004 14:12:29 +0700 (KRAT) From: Eugene Grosbein To: FreeBSD-gnats-submit@freebsd.org Cc: Subject: init(8) may keep zombies X-Send-Pr-Version: 3.113 X-GNATS-Notify: >Number: 64198 >Category: bin >Synopsis: [patch] init(8) may keep zombies >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: closed >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri Mar 12 23:40:00 PST 2004 >Closed-Date: Sat Jul 08 15:35:34 GMT 2006 >Last-Modified: Sat Jul 08 15:35:34 GMT 2006 >Originator: Eugene Grosbein >Release: FreeBSD 4.9-STABLE i386 >Organization: Svyaz Service JSC >Environment: System: FreeBSD www.svzserv.kemerovo.su 4.9-STABLE FreeBSD 4.9-STABLE #4: Wed Mar 3 12:48:22 KRAT 2004 eu@www.svzserv.kemerovo.su:/home4/obj/home/src/sys/WWW i386 >Description: ttys(5) provides a way to run an application before starting main process for terminal line. One can use 'window="..."' for it. Let's look how init(8) impelents this: 1. It forks to serve a line, obtains PID1. 2. It forks again and executes a command written as window argument, if needed. It obtains PID2. 3. It sleeps for WINDOW_WAIT == 3 seconds. 3. It executes main process for terminal line. This process will have PID1 and PID2 will be a child of PID1. PID2 may become a zombie until PID1 finishes if PID2 finishes during the stage 3. init(8) will not call waitpid() in this case. >How-To-Repeat: 1. Make user 'systat' and make the following shell script for its login shell: #!/bin/sh exec nice -10 systat -vm 3 2. Add a record to /etc/gettytab: systat|autologin systat display:\ :al=systat:tc=Pc: 3. Make a record in /etc/ttys: ttyv9 "/usr/libexec/getty systat" cons25 on secure window="/bin/stty susp undef stop undef kill undef quit undef" 4. Make init reread /etc/ttys: kill -1 1 5. Look at stty zombie. >Fix: Teach init(8) to call waitpid() even if a child is not found by the find_session() function. >Release-Note: >Audit-Trail: From: Eugene Grosbein To: bug-followup@freebsd.org Cc: stable@freebsd.org Subject: Re: bin/64198: init(8) may keep zombies Date: Mon, 9 May 2005 22:31:41 +0800 Hi! The problem is still here for 5.4-STABLE: http://www.freebsd.org/cgi/query-pr.cgi?pr=bin/64198 Eugene Grosbein From: Eugene Grosbein To: bug-followup@freebsd.org Cc: stable@freebsd.org Subject: Re: bin/64198: init(8) may keep zombies Date: Wed, 28 Dec 2005 03:27:12 +0700 Hi! The problem is still here for 6.0-STABLE: http://www.freebsd.org/cgi/query-pr.cgi?pr=bin/64198 For this version init leaves a process not in 'Z' (zombie) state but in 'RE' (trying to exit) state that's strange. Eugene Grosbein From: Kostik Belousov To: bug-followup@FreeBSD.org, eugen@grosbein.pp.ru Cc: Subject: Re: bin/64198: init(8) may keep zombies Date: Thu, 29 Dec 2005 15:35:23 +0200 The following patch fixes cosmetic problem with zombie. For RE state in ps output, see PR/91044. Index: sbin/init/init.c =================================================================== RCS file: /usr/local/arch/ncvs/src/sbin/init/init.c,v retrieving revision 1.61 diff -u -r1.61 init.c --- sbin/init/init.c 15 Sep 2005 13:16:07 -0000 1.61 +++ sbin/init/init.c 28 Dec 2005 15:56:06 -0000 @@ -1066,6 +1066,7 @@ 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 @@ /* 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); From: Eugene Grosbein To: bug-followup@freebsd.org Cc: Kostik Belousov Subject: Re: bin/64198: init(8) may keep zombies Date: Fri, 6 Jan 2006 18:23:01 +0700 > The following patch fixes cosmetic problem with zombie. Thank you, your patch works. Eugene Grosbein State-Changed-From-To: open->closed State-Changed-By: kib State-Changed-When: Sat Jul 8 15:34:52 UTC 2006 State-Changed-Why: Patch committed to HEAD and RELENG_6. http://www.freebsd.org/cgi/query-pr.cgi?pr=64198 >Unformatted: