Click to See Complete Forum and Search --> : fork question


debiandude
06-17-2002, 09:12 AM
Im writing a timer program. However I need to know if my child finishes exiting and quits. Is there a signal I could listen to that tells me the process has quit?

Stuka
06-17-2002, 09:39 AM
In the parent process, you use waitpid() - the man page will tell you more, but that's what (literally) waits for the child process to exit.

l01yuk
06-17-2002, 10:07 AM
SIGCHLD is what you are looking for. It is sent by the child to the parent on _exit().

debiandude
06-17-2002, 10:26 AM
Thanks, SIGCHLD was exactly it. Grazie!

bwkaz
06-17-2002, 12:51 PM
Well, all that wait() and waitpid() do is just block until the process receives a SIGCHLD.

Just FYI.

Stuka
06-17-2002, 02:10 PM
Well, glad to know I'm not a complete idiot! (Actually, I KNEW I was right, since I just wrote a short piece of code using waitpid() for my class last night!).

debiandude
06-17-2002, 02:13 PM
See but I couldn't just call waitpid becuase I wouldn't be able to execute other things in the mean time. What I did was set up a signal cather to SIGCHLD and interupt what ever Im doing.

Stuka
06-18-2002, 09:38 AM
Well, NOW you tell me!

debiandude
06-18-2002, 01:05 PM
I know I know. I have this bad habit of assuming that everyone know whats going on in my head. Funny thing is half the time I don't even know whats going on up there ;-)