Discussion:
Sys_Exit
(too old to reply)
David Marcin
2005-09-20 17:12:15 UTC
Permalink
In light of our newfound ability to background processes, Sys_Exit is
what I would consider a bit buggy. It is possible for a process to
spawn several child foreground processes and then exit (by not calling
Wait on them). After it exits the system is in a bit of an inconsistent
state because a few processes have invalid parent pointers and invalid
refcounts. It seems only right that Sys_Exit would "clean up" after a
process by orphaning the child processes and decrementing their refcount.

Note that it is still possible to have zombie processes. A process
"spawn.exe" could spawn several foreground instances of b.exe and then
wait on long.exe several times. During the time spawn.exe is waiting on
long.exe, the instances of b.exe would be zombies. However, when
spawn.exe exits, the zombie b.exe processes would be reaped as a result
of Sys_Exit cleaning up.

Should we do this, or should we leave Sys_Exit as is?
Saurabh Srivastava
2005-09-20 18:42:05 UTC
Permalink
| In light of our newfound ability to background processes, Sys_Exit is
| what I would consider a bit buggy. It is possible for a process to
| spawn several child foreground processes and then exit (by not calling
| Wait on them). After it exits the system is in a bit of an inconsistent
| state because a few processes have invalid parent pointers and invalid
| refcounts. It seems only right that Sys_Exit would "clean up" after a
| process by orphaning the child processes and decrementing their refcount.

No. I am of the opinion that if the user level code does not conform to
the semantics of spawning foreground processes then the creation of
zombies is expected. The only way to get them cleaned out of the system
would be to use our newfound ability to Sys_Kill them. :)

|
| Note that it is still possible to have zombie processes. A process
| "spawn.exe" could spawn several foreground instances of b.exe and then
| wait on long.exe several times. During the time spawn.exe is waiting on
| long.exe, the instances of b.exe would be zombies. However, when
| spawn.exe exits, the zombie b.exe processes would be reaped as a result
| of Sys_Exit cleaning up.
|
| Should we do this, or should we leave Sys_Exit as is?
|

I agree that this will give you a system with fewer zombies lying around.
But it doesnt seem reasonable for the kernel to expend the energy to go
through the entire threadlist (which, for the sake of argument, lets say,
is of the order of thousands) on each Sys_Exit. The user process is
responsible for keeping track of its foreground processes and we should
not penalize the kernel's efficiency for the handling of a few faulty
processes.

Continue reading on narkive:
Loading...