this sequel How to compress additional parameters of the header function when the parent signal is told to kill the child (c)?
In my reaper (), I am trying to get the child pid that the parent is about to finish (this is not a cruel word). but wait () does not return the pid of the child; instead, it returns 1. I cannot find a document for return value 1 anywhere. Any heads?
void reaper(int sig) { int status, killedpid; while(killedpid = (/*waitpid(-1, &status, WNOHANG)*/wait(&status)) >= 0) { printf("reaper %d killed %d\n", getpid(), killedpid); } }
My results:
reaper 5933 killed 1 //actual child pid is 5936
Thank you in advance!
- ( precedence ):
if ( killedpid = ( wait( &status ) >= 0 )) { ...
killedpid TRUE, 1 C. , , -Wall -pedantic:
killedpid
1
-Wall -pedantic
if (( killedpid = wait( ... )) >= 0 ) { ...