Subject: Re: CVS commit: src/usr.sbin/rpc.lockd
To: None <christos@zoulas.com>
From: Ben Harris <bjh21@netbsd.org>
List: tech-userlevel
Date: 03/14/2003 15:32:12
In article <HBqw4r.581@tac.nyc.ny.us> you write:
>In article <20030314135309.AB5CAB004@cvs.netbsd.org>,
>YAMAMOTO Takashi <yamt@netbsd.org> wrote:
>>
>>Module Name:	src
>>Committed By:	yamt
>>Date:		Fri Mar 14 13:53:08 UTC 2003
>>
>>Modified Files:
>>	src/usr.sbin/rpc.lockd: lockd_lock.c
>>
>>Log Message:
>>for fork'ed children, use _exit instead of exit.
>
>Is there a reason for that change? Using _exit() avoids doing the
>stdio cleanup and the atexit calls.  It is recommended for vfork()
>where the address space of the parent and the child are shared
>after the vfork() and before the exec(). There is no reason to do
>it for fork(), right?

If there's pending output in the stdio buffers before the fork, it'll end up
in the stdio buffers of both the parent and the child afterwards.  Flushing
both is bad, so you usually only call exit() in the parent, and call _exit()
in the child.  The same thing applies to most other things that exit() does
and _exit() doesn't.

-- 
Ben Harris                                                   <bjh21@netbsd.org>
Portmaster, NetBSD/acorn26           <URL:http://www.netbsd.org/Ports/acorn26/>