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
Post a Comment