shell tricks and trapping signals

Bill Freeman f at ke1g.mv.com
Sat Nov 3 09:46:05 EDT 2007


Paul Lussier writes:
 > "Ben Scott" <dragonhawk at gmail.com> writes:
 > 
 > >   Can't you trap on the HUP (hang-up) signal for that?  Or is the
 > > process not running with a tty attached?
 > 
 > No, and exactly.  Essentially, our test suite opens a pipe to ssh and
 > treats ssh as an IPC interface.  It lobs commands across the ssh
 > tunnel with no attached tty.
 > 
 > The ssh tunnel can collapse, and any spawned process is essentially
 > orphanned to be reparented by init.  We want the spawned process to
 > trap on that re-parenting.

Doesn't the ssh end of the pipe get closed?  And assuming that you
have two pipes for two way communications, doesn't a read on the pipe
for data toward the script return EOF?

Or, since the pty is still being held open by ssh (or the process would
have already been reparented), can you just leave the process attached,
but ignoring the fd (even if you have to dup it off to another fd>2)?

Bill


More information about the gnhlug-discuss mailing list