in reply to Killing a process and, recursively, all its children

I think killing the negative of a process kills it and all it's children, as a 'process group'.

--Bob Niederman, http://bob-n.com
  • Comment on Re: Killing a process and, recursively, all its children

Replies are listed 'Best First'.
Re: Re: Killing a process and, recursively, all its children
by bronto (Priest) on Aug 12, 2003 at 14:02 UTC
    bsb> I've not tried this but "man kill" says: ...

    bobn> ...I think killing the negative of a process kills it and all it's children, as a 'process group'.

    I tried the "process group" approach before posting, even if I had many doubts it could work. And in fact, it didn't: killing the process group means killing the daemon, too, since it is part of the process group of its children.

    Ciao!
    --bronto


    The very nature of Perl to be like natural language--inconsistant and full of dwim and special cases--makes it impossible to know it all without simply memorizing the documentation (which is not complete or totally correct anyway).
    --John M. Dlugosz

      Assuming you have some sort of access to the POSIX layer (via XS, libraries, etc.) you can put your child processes in their own process group with setpgid:

      The setpgid() and setpgrp2() system calls cause the process specified by pid to join an existing process group or create a new process group within the session of the calling process. The process group ID of the process whose process ID is pid is set to pgid. If pid is zero, the process ID of the calling process is used. If pgid is zero, the process ID of the indicated process is used. The process group ID of a session leader does not change.

      You could have your parent proces set the process group of the children when it makes them and it should automatically propogate to any sub-children they make, etc. I think.