in reply to Re: Stopping subprocesses
in thread Stopping subprocesses

I don't think that will work because if B ends before C, then C will adopt a new parent and that parent isn't A. So, there's no way to know that C is a descendent of A.

Replies are listed 'Best First'.
Re^3: Stopping subprocesses
by dasgar (Priest) on Aug 24, 2010 at 18:27 UTC

    Hmmm....Two thoughts about that.

    First: Assuming that script B on its own won't end without its child processes to end first, I think that calling pkill from script A will kill script B's child processes. Then if script A kills script B directly, then you won't hit that issue. Of course, I may be assuming more than I should or assuming incorrectly.

    Second: If script B is coded such that it can call die without killing its child processes, I would think that there should be a way to modify the code to call pkill first to kill its child processes before actually exiting out. Of course, if something else is killing from the OS, then you might have the orphaned processes as you described.

    I'm not disagreeing with you. Just thinking out loud in case any of this might be helpful for you or others to figure out a solution. That and hoping that I don't sound like a blabbering idiot. :D