[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: Failure to kill pid



John Hawk (john.hawk@gte.net) wrote:
> The code below creates a fork to run grep.
> Code works correctly except for KILL resulting in an inability
> to reuse a grep file search.  The question is why the PID goes Zombie vs
> being killed. Replace the PID with 0 and parent is killed as expected.
> Suggestions ?

[snip]

> void sigchld_handler (gint signal)
> {
>     close (TASK_HANDLE);
>     kill (TASK_PID,9);
>     TASK_WORKING = FALSE;
> }

Why do you want to kill() the child if it is already dead? The child is
already dead, otherwise you wouldn't have got the SIGCHLD. Anyway, to
avoid zombies, you have to wait() or waitpid() in the SIGCHLD handler.


Erik

-- 
J.A.K. (Erik) Mouw, Information and Communication Theory Group, Department
of Electrical Engineering, Faculty of Information Technology and Systems,
Delft University of Technology, PO BOX 5031,  2600 GA Delft, The Netherlands
Phone: +31-15-2785859  Fax: +31-15-2781843  Email J.A.K.Mouw@its.tudelft.nl
WWW: http://www-ict.its.tudelft.nl/~erik/




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]