Allow for passing Ctrl-C and don't mix stderr with stdout

Ron Frederick ronf at timeheart.net
Thu Jul 17 15:17:49 EST 2014


On Jul 16, 2014, at 3:24 AM, Ole Tange <tange at gnu.org> wrote:
> I have been losing my mind over this problem, so any ideas are welcome.
> 
> When running non-interactive jobs on remote machines, I want output to
> stderr and to stdout to remain separate in two streams just as if they
> were run locally. I also want jobs running remotely to die when I
> press Ctrl-C just as if they were run locally.

With OpenSSH, you can only get separate stdout and stderr streams if you don’t allocate a pseudo-tty when you open up the SSH session. If you allocate a tty, the remote program can still have separate stdout and stderr, but whichever of those is directed to the pseudo-tty will be output by the local ssh client on stdout and nothing with go to the local stderr. Running with ‘-tt’ forces a pseudo-tty allocation and that will lose the stdout/stderr independence for the reasons explained in the stackexchange.com response related to having only a single pseudo-tty fd to read the output from. If you want separate stdout & stderr, you need to find a different way to trigger the interrupt signal.

The SSH protocol provides a way for a client to send signals to the remote system without relying on a pseudo-tty, but I don’t think OpenSSH implements this feature yet (on either the client or server side). With it, it might be possible to add a ‘~’ SSH escape sequence which you could use instead of the Ctrl-C, similar to the way ‘~B’ sends a break request or ‘~R’ trigger key renegotiation. Without it, though, I can’t think of an easy way to accomplish what you are asking.
-- 
Ron Frederick
ronf at timeheart.net





More information about the openssh-unix-dev mailing list