Catching termination of child process and system() call

YANG Liqun yang at nff.ncl.omron.co.jp
Wed Jan 23 15:31:30 AEST 1991


In article <15745vrm at cathedral.cerc.wvu.wvnet.edu> Vasile R. Montan writes:

> ... I put the following in my main routine:
> 
> void dowait()
>{
> wait(0)

It should be wait((int *)0).

>main()
> {
>   ...
>  signal(SIGCHLD, dowait);
> ...
> }

When a child process stopped or exited, SIGCHLD signal will be sent to the
process and wait system call itself will catch the SIGCHLD signal from a
child. So you do not need to use 
signal(SIGCHLD, dowait);
just use
   wait(&ret_val)
in parent process.

I think the problem of your code is that a SIGCHLD signal is sent to
parent process when a child process dies, but the signal is caught and
then invoke a wait system call which will wait for another SIGCHLD signal.

Yang.

-----
Li-qun Yang                  OMRON Computer Technology R&D lab
yang at nff.ncl.omron.co.jp     tel: 075-951-5111  fax: 075-956-7403

--
;  Li-qun Yang			OMRON Computer Technology R&D lab
;  yang at nff.ncl.omron.co.jp	tel: 075-951-5111  fax: 075-956-7403



More information about the Comp.lang.c mailing list