Pergunta

I am using waitpid as given

waitpid(childPID, &status, WNOHANG);

This is used in a program inside an infinite loop that forks when needed and the parent waits for the child process to return. But recently I have come across a problem where in the program exits after printing this to the cerr..

waitpid: No child processes

This is always the last log from the program before it crashes/exits. I know that it doesnot segfault or anything because i have a traceback function written that prints the last 10 addresses that the program accessed. So does it mean that the program exited the loop after finding that there is no child process? Or is there something sinister at work here?

Foi útil?

Solução

I guess what is happening over here is that the fork system call is failing due lo lack of available entries in the process table. You can do a perror on the output of fork. I think it should be RESOURCE_TEMPORARILY_UNAVAILABLE.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top