C Parent/Child exit variable -


i working on program , learning parent/child processes. childprocess

exit(variable); 

in main() have:

signal(sigchld, chldhandler); 

outside main() have:

void chldhandler(int sig) {  } 

how access variable chldhandler?

you use wait() inside signal handler, passing in non-null pointer status.

int status; wait(&status); 

to decode status, check see exited normally, use wexitstatus() macro:

if (wifexited(status)) {     int variable = wexitstatus(status);     /*...*/ } 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -