shell tricks and trapping signals

VirginSnow at vfemail.net VirginSnow at vfemail.net
Fri Nov 2 17:15:46 EDT 2007


> From: Paul Lussier <p.lussier at comcast.net>
> Date: Fri, 02 Nov 2007 10:13:22 -0500

> Since we're on the topic of shell tricks, does anyone know of a way to
> trap on a processes PPID getting re-parented?
> 
> By way of example:
> 
> -  Our test infrastructure initiates an ssh session to a remote machine.
> -  On the remote machine, a process is spawned.
> -  At some timeout, the ssh session is terminated, effectively
>    orphanning the process it spawned.
> -  The spawned process is re-parented to PID 1 (init).
> -  I want to trap on this, cleanup, and exit.

Maybe you could spawn ssh from a "child watcher" which wait()s on the
entire process group.  Then, when the ssh process terminates, it sends
a KILL to every other process in the group.  This seems like the kind
of thing someone should have written a shell utility for years ago...


More information about the gnhlug-discuss mailing list