so I was wondering why there are some hanging SSH connection left from some of my automated scripts and I came to a weird issue - SSH, if used without PTY, doesn't terminate when the output pipe gets closed. This has already been discussed in several other questions here, but I didn't find an applicable answer - some people adviced to use
-t option, but that requests the PTY and piping doesn't work.
Anyway, I reduced the issue to following minimal example:
#this works cat /dev/zero |false #this never terminates ssh user@host "cat /dev/zero" |false
Is there any explanation why would SSH ignore SIGPIPE that rises from writing to already dead pipe (the one that led to false), or any method to make this "work" correctly?
Note that "relaying" the SIGPIPE to the remote host isn't needed - simply killing the ssh client (which is what would exactly happen without ignoring SIGPIPEs) leads to same result with less complexity and some "more correct" assumptions.
Thanks for your ideas!
EDIT: happens only on Sun_SSH server, looks like some kind of undocumented issue. I'm searching for some good workaround.