Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!cbosgd!gatech!msdc!terry From: terry@msdc.UUCP (Terry Countryman) Newsgroups: net.bugs.4bsd Subject: BRL Release 3 BSD4.2 /etc/syslogd forgets about its children Message-ID: <129@msdc.b.msdc.UUCP> Date: Tue, 11-Feb-86 20:44:24 EST Article-I.D.: msdc.129 Posted: Tue Feb 11 20:44:24 1986 Date-Received: Sat, 15-Feb-86 01:18:27 EST Organization: Medical Systems Development Corp., Atlanta GA Lines: 74 Keywords: BRL, syslogd, zombies, wait In the last week or so I have been configuring the syslog daemon(s) for our 4.2 systems so that we can be notified quickly of possible system problems (there isn't an operator in the computer room all of the time). Using the ability to "network" the log messages over to our development system and having 4 or 5 people in the notify list started putting /etc/syslogd through its' paces. Then I started noticing large numbers of zombies with syslogd as the parent. Going to the code, I found that syslogd forks a process for each person/logfile that gets the log messages. But it never waits on those children; an excellent way to generate zombie processes. Below is the fix that I came up with. ------------------------------------------------------------------------- *** /tmp/,RCSt1006581 Wed Jan 29 20:23:22 1986 --- syslogd.c Tue Jan 28 18:55:58 1986 *************** *** 49,54 #include #include #include #include #include --- 49,57 ----- #include #include #include + #include + #include + #include #include #include *************** *** 685,690 struct utmp ut; long now; char line[MAXLINE + 100]; /* open the user login file */ if ((uf = fopen("/etc/utmp", "r")) == NULL) { --- 688,694 ----- struct utmp ut; long now; char line[MAXLINE + 100]; + union wait waitbuf; /* open the user login file */ if ((uf = fopen("/etc/utmp", "r")) == NULL) { *************** *** 759,764 /* close the user login file */ (void) fclose(uf); } /* --- 763,772 ----- /* close the user login file */ (void) fclose(uf); + + /* cleanup after ourself; collect the children that are ready */ + while (wait3(&waitbuf, WNOHANG, (struct rusage *)0) > 0) + continue; } /* -----------------------------------------------------------------------------