[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Pexec :)



Your child processes are in an EXIT state because their parent (your
program) hasn't yet read their exit status; whenever a program is launched
asynchronously, its process table entry remains until its parent does a
Pwait() call to find its exit status. There are several solutions to your
problem:
(1) I think there's a Pwait() call that's non-blocking and returns immediately
if there are no zombie children; you could insert this into your program's 
main loop.
(2) You could set up an interrupt handler for SIGCHLD that does the Pwait()
and collects info. SIGCHLD will be sent whenever one of your children
exits.
(3) You could do a Psignal(SIGCHLD, SIG_IGN). I think this will tell the
kernel you're no longer interested in the status of child processes (it's
been a while since I looked at this, so check the manuals).
(4) You could do the spawning "two layers" deep; spawn a child, and
then have that child run the new process asynchronously and then exit.
Since the grandchild no longer has a parent, the kernel will remove its
process table entry as soon as it exits. The second level "spawner"
process shoulld be run synchronously, of course, or else you'll be
right back where you started :-).

Regarding restricting the amount of memory a process is given when it
starts: the kernel already supports this. See the Plimit() system
call.