Date: Wed, 13 Dec 1995 18:45:39 +0100 (MET) From: grog@lemis.de (Greg Lehey) To: terry@lambert.org (Terry Lambert) Subject: Re: samaphore remains Message-ID: <199512131745.SAA01254@allegro.lemis.de> In-Reply-To: <199512061915.MAA01689@phaeton.artisoft.com> from "Terry Lambert" at Dec 6, 95 12:15:29 pm
next in thread | previous in thread | raw e-mail | index | archive | help
Terry Lambert writes: > >> Currently I'm using FreeBSD-R2.1.0-RELEASE on GATEWAY 2000 P5-90. >> >> I found the trouble that if a program using semaphore died >> anbormally, the semaphore which was created remains on kernel. >> I think it should be released by kernel's exit() function. >> >> Although one of the UNIX implementation calls semexit() routine from >> exit(), FreeBSD doesn't call semexit() from anywhere. >> Is there any reason for this? >> >> >> I tried to fix the exit() as follows and it seems working well. >> >> ------------- cut here --------------- >> *** kern_exit.c Tue May 30 17:05:25 1995 >> --- kern_exit.c.new Wed Dec 6 15:12:28 1995 >> *************** >> *** 130,135 **** >> --- 130,139 ---- >> */ >> fdfree(p); >> >> + #ifdef SYSVSEM >> + semexit(p); >> + #endif >> + >> /* The next two chunks should probably be moved to vmspace_exit. */ >> vm = p->p_vmspace; >> #ifdef SYSVSHM >> ------------- cut here --------------- >> >> >> -- >> Mihoko Tanaka >> <m_tanaka@pa.yokogawa.co.jp> > > This looks exactly right. That's a matter of definition. In System V, by default the semaphore remains beyond the death of the process. See "The Magic Garden Explained", pp 541 et seq., for an explanation which even makes this apparent nonsense make sense. The correct behaviour is to only reset the semaphore if the SEM_UNDO flag is set. I can't see any reason to ever have it not set, but maybe some broken System V software relies on it... Greg
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199512131745.SAA01254>