tags:

views:

11

answers:

0

I have a shell script that starts an ssh session to a remote host and pipes the output to another, local script, like so:

#!/bin/sh
ssh user@host 'while true ; do get-info ; sleep 1 ; done' | awk -f parse-info.awk

It works fine. I run it under the 'supervise' program from djb's daemontools. The only problem is shutting down the daemon. If I terminate the process for this shell script, the ssh and awk processes continue running as orphans. Normally I would solve this problem with exec to replace the supervising shell process, but the two processes run in their own subshells and can't replace the shell process.

What I would like to do is have the supervising shell script 'forward' any signals it receives to at least one of the child processes, so that I can break the pipe and shut down cleanly. Is there an easy way to do this?