Author: Stan Eisenstat
Subject: Re: [Cs323] waitpid, wexitstatus, wifexited
Date: Sunday, 15 Nov 2020, 07:25:22
> Message Posted By: Unknown > > What actually sets the status int in waitpid? Is that when the child > process executes that the status pointer is updated with whatever the > status of that child process was? ... Assume that waitpid(pid,&status,0) is called and that process pid is a child of the current process that is still running. When the child terminates, the operating system sets *status to its status (which includes either the signal that caused it to terminate, or the low-order byte of the argument to exit() or the value returned by main()) and returns the pid of the child as the value of waitpid(). ===== > ... Also, how do WIFEXITED() and WEXITSTATUS > still work after the child process exit and are completed? From the pipe.c > example, it looks like it is somehow able to remember values of WIFEXITED > and WEXITSTATUS just from the status int? I'm a bit confused from the man > page. WIFEXITED() and WEXITSTATUS() are macros that extract information from the status variable set by the call to waitpid() or wait(). --Stan-PREV INDEX NEXT