Re: ssh SIGHUP behavior with remote commands



On Mon, 17 Jul 2006, Ryan Olf wrote:

I use ssh (OpenSSH_4.3p2, OpenSSL 0.9.7j on Gentoo Linux kernel 2.6.15) to run
a command on a remote machine (same version) that doesn't terminate without
an explicit kill. Is it possible to send this signal through ssh without
using a login shell? Ideally, I'd be able to run "ssh server command," and
then send SIGHUP to to the ssh process, which would result in it sending some
signal to the command. However, the current behavior is that command is left
running while ssh terminates. Alternatively, is it possible to tell ssh to
send a signal to a command it is running on a remote server?

I searched google and saw that there has been some discussion of similar
issues in the past, but am not clear how/if it was resolved. Thanks a lot
for the help,

I can give you some vague answers, centered around "you can't".

I investigated OpenSSH's sshd a while back (maybe 4.1 or late 3.x) and
it had no logic for dealing with signals it received via the SSH protocol.
Too bad. I did some work on adding that code, but didn't finish it.

We produce an SSH client for Windows. My goal was to be able to send
signals, especially a SIGHUP that could act as a "conditional
termination", instead of blindly quitting the client side. If the client
sent SIGHUP, and the host software was at a point where it could quit
cleanly, it would respond to the signal by logging out. OTOH, if it was in
a critical point, it could block that signal and not respond to it.
Properly executed, this combination could prevent orphan processes and
corrupted databases.

I'd be interested in hearing from anyone who has done similar work.

Regards,
....Bob Rasmussen, President, Rasmussen Software, Inc.

personal e-mail: ras@xxxxxxxxx
company e-mail: rsi@xxxxxxxxx
voice: (US) 503-624-0360 (9:00-6:00 Pacific Time)
fax: (US) 503-624-0760
web: http://www.anzio.com



Relevant Pages

  • Using SSH to terminate remote systems for disaster recovery
    ... I have a need to terminate a number of AIX 5.1 systems ... from a single script. ... I can do this using ssh. ... if I issue the shutdown command from ssh, ...
    (AIX-L)
  • Re: Variable I/O Performance with dd vs. cat
    ... The only issue here is the seriously misnamed "kill" command. ... default action for most other signals is also to terminate the process ... Only a few signals cannot be intercepted, ...
    (comp.os.linux.misc)
  • ssh SIGHUP behavior with remote commands
    ... a command on a remote machine that doesn't terminate without ... Is it possible to send this signal through ssh without ...
    (SSH)
  • Re: aborting a bash script with control-c
    ... If you use the proper signal names, it is guaranteed to terminate the shell. ... A couple of signals can be generated from the keyboard, ... Signals are only acted upon when a process is transitioning from executing ... your trap command does not guarantee all of the ...
    (comp.unix.shell)
  • Re: ssh timeout script
    ... terminate due to inactivity. ... I wanted to do a script that when the ssh ... session is provoked it sends a date command to the screen and then every ... 10 minutes of inactivity sends the output of the date command to the ...
    (comp.unix.shell)