Question

I have a dead process that is now in the defunct state which means that its parent process has not read its exit value. (and it is not going to read it)

I know that the exit value is stored somewhere in the kernel for the parent process to read but, is there a way for me to read that value if I am not the parent process ?

Ideally, I would be able to do this from a shell or an abritrary C/python/your-favorite-language program.

[edit]: This is not a question on how to reap the child or kill it. I do not care if it uses up a slot in the process table. I just want to know what its exit value is. i.e., I would like to read task_struct->exit_code in the kernel.

Mathieu

Was it helpful?

Solution

No. Attempting to call waitpid() for a process that is not one of the calling process's children will result in ECHILD. You will need to kill the parent process, causing the child to reparent to init, which will subsequently reap it.

OTHER TIPS

One thing you might be able to do is to send the parent SIGCHLD, which tells it that a child has died. If the program is of any quality, it will reap the process.

kill -s SIGCHLD parentpid
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top