Getting a child process status (C)
I am creating a simple shell, in which I can run a process in the background using the '&' option. I am starting a process and calling waitpid(pid, status, WNOHANG), which allows it to continuously check to see if the process is complete. Now, the problem I am facing is printing a message when a child process completes.
Is there any way to use waitpid() to report back when a process completes? Or is there a function to get the list of running processes and somehow store those to continuously check to see if a process has finished? Or, does anyone have any other suggestions as to how I should go about this? Thank you. |
Quote:
Please read "man waitpid" for more information on how to check if it exited. <edit> I noted that you call waitpid() passing the variable status without taking it address with &. This is not necessarily a problem if status is a pointer to an int, e.g. something like: Code:
int st; </edit> |
Got it working, thanks for your input!
|
All times are GMT -5. The time now is 05:06 PM. |