On Thu, 01 May 2003 15:38:48 -0700
dries
Jerry Feldman wrote :
| If you have a small test program that exhibits this problem, could you| send it to me. When things should work, but do not, there is generally| something else involved.
Well, that's part of the problem, i can't get this faulty situation to occur on my own machine, i can only get it to appear on a slower (300 Mhz) PC. I think the problem has got something to do with task-swaps and timing since on the slower PC it happens regularly but not 100% of the time. Since the PC is slower it spends more time in the kill-waitpid sequence (these commands are right behind one another in my source), thus giving a higher change that a taskswap is performed in this timeframe. Beware that i am just guessing here !.
But to shortly answer your question, no, i haven't been able to make a program that shows this behaviour on my PC. sorry about that. (the same program that fails on the slower machine passes on a faster machine.
What is notable is that the waitpid is passed, it returns immediately so waitpid sees that the process is ended. Still a zombie appears.
So, you are saying that waitpid returns -1.
Does the zombie remain until you log out?, or does it eventually
terminate itself?
Possibly it is waiting on a page fault or there was a missed signal.
I would still add a signal handler on SIGCHILD in the parent. For the
handler, simply put in a simple wait(2):
void HandleSigchild(int sig)
{
pid_t rv;
if (sig == SIGCHILD) {
rv = wait(NULL);
}
}
It won't hurt to add this. I normally use sigaction(2) to set up the
signal handlers, but you can also use the older signal(2) system call
also.
--
Jerry Feldman