ignoring SIGPIPE causing problems in pipes
Markus Friedl
markus.friedl at informatik.uni-erlangen.de
Sun May 27 01:50:34 EST 2001
On Fri, May 25, 2001 at 07:19:45PM -0400, Ed L Cashin wrote:
> nilda:2:ecashin openssh-2.9p1$ ssh meili yes | (for i in 1 2 3 4; do echo $i; read line; done)
> ..
> Hope this helps. I suppose it would be most of interest to the person
> who made the change, since version 2.5.2p2 works fine:
this is because 2.5.2 defaults to protocol v1 whereas 2.9
defaults to v2.
ok, i can reproduce this problem with
$ ssh -2 -v -v -v localhost yes | sed 2q
whereas
$ ssh -1 -v -v -v localhost yes | sed 2q
works fine.
in protocol 2 ssh detects that it can no longer write to the sed
process. however, it never tries to read from sed, so it does not
exit.
you can work around this with
$ ssh -n -2 -v -v -v localhost yes | sed 2q
and force ssh to ignore input and replace stdin with /dev/null
btw, the same happens if i try this with ssh.com's ssh2 client.
i'm not sure what the right thing to do is in this situation.
clientloop.c needs to ignore SIGPIPE, because of all
the portforwarding code needs this. should select() return
if 'sed' dies?
More information about the openssh-unix-dev
mailing list