[Adium-devl] rev 19069 - in branches/adium-1.0/Plugins/Gaim Service: . Libgaim.framework/Versions/A/Headers
Peter Hosey
boredzo at gmail.com
Sun Feb 25 08:24:27 UTC 2007
On Feb 24, 2007, at 18:33:03, Evan Schoenberg wrote:
> No member of the wait() family is called in dnssrv.c... is standard
> practice that it should be used somewhere, then?
Yes.
When a process exits, its exit information (exit status and a few
other things) is kept around so that when the parent process calls
wait(2) (or waitpid, or some other wait* function), it can then be
returned. The information is kept in a specially-marked row in the
process table. Such a process is called a zombie, since it's not
technically “alive” (it exists only for its parent's benefit) but it
still is shambling around in the process table.
The idea is that the parent will call wait soon, if not immediately.
Consider a primitive shell:
1. Parse command-line into an argv (using strtok if it's really
primitive; a beefier parser otherwise).
2. fork.
Child:
3. exec the argv.
Parent:
3. Call waitpid with the result of fork.
There's no delay in between 2 and 3 in the parent, nor is there an
event loop polling wait(2) with WNOHANG (non-blocking)*. It calls
waitpid without WNOHANG, so that it blocks until the child exits.
That's exactly what you see as the user: The child starts, runs, then
exits, at which point the shell (which has just now finally received
a result from waitpid) displays its prompt for the next command.
So when you don't call wait, that zombie is left wandering around
forever. It should die when its parent exits, though. (Apps launched
through LS/NSW are children of WindowServer, but processes created by
calling fork directly are children of the process that called fork.)
* Not true when the command is invoked using &, of course. Then the
shell does use an event loop and WNOHANG.
___________________________________
\ Peter Hosey / boredzo at adiumx.com
PGP public key ID: C6550423 (since 2007-01-01)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 186 bytes
Desc: This is a digitally signed message part
URL: <http://adium.im/pipermail/devel_adium.im/attachments/20070225/d43c6615/attachment.sig>
More information about the devel
mailing list