Bug 85 - ssh -2 localhost od /bin/ls | true ignore SIGPIPE
Summary: ssh -2 localhost od /bin/ls | true ignore SIGPIPE
Status: CLOSED FIXED
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: ssh (show other bugs)
Version: -current
Hardware: All All
: P2 normal
Assignee: OpenSSH Bugzilla mailing list
URL:
Keywords:
Depends on: 830
Blocks: 403 773 V_5_1
  Show dependency treegraph
 
Reported: 2002-01-30 09:39 AEDT by Markus Friedl
Modified: 2008-07-22 12:06 AEST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Friedl 2002-01-30 09:39:32 AEDT
% ssh -2 localhost od /bin/ls | true
transfers and discards data, while protocol v1 does not:
% ssh -1 localhost od /bin/ls | true      
Write failed flushing stdout buffer.
write stdout: Broken pipe
%
Comment 1 Markus Friedl 2002-01-30 09:49:20 AEDT
fix chan_close/dead/gc:
        user_detach decides:
        send a close only after a close received or always?
        server: delay close until exit message has been sent?
        client: always send close ?

Comment 2 Jason Lunz 2003-01-25 04:20:09 AEDT
What's wrong with the following obvious patch? This fixes the bug for me
(without this, our network backups hang forever if the tape fills up).

diff -ur openssh-3.5p1.orig/clientloop.c openssh-3.5p1/clientloop.c
--- openssh-3.5p1.orig/clientloop.c     Wed Sep  4 02:32:13 2002
+++ openssh-3.5p1/clientloop.c  Fri Jan 24 12:16:02 2003
@@ -892,6 +892,7 @@
        signal(SIGINT, signal_handler);
        signal(SIGQUIT, signal_handler);
        signal(SIGTERM, signal_handler);
+       signal(SIGPIPE, signal_handler);
        if (have_pty)
                signal(SIGWINCH, window_change_handler);

Comment 3 Markus Friedl 2003-01-26 01:03:15 AEDT
i think SIGPIPE can happen in x11-fwding and should not lead to exit(1)
Comment 4 Chris Lightfoot 2006-06-22 08:50:05 AEST
I see this bug has now been open for more than four years, with no sign of a fix -- I guess everyone must have a workaround for this issue. Any suggestions, since I haven't been able to find a reliable one...?
Comment 5 Jonathan Stimmel 2006-12-28 04:24:19 AEDT
I am running into this as well, and have not found a workaround.
Comment 6 Damien Miller 2008-05-09 14:41:19 AEST
The problem seems to be that protocol 2 lacks a way to "half close" a channel, e.g. close its output while keeping its input open.

Markus, does this seem right?
Comment 7 Markus Friedl 2008-05-09 15:04:26 AEST
(In reply to comment #6)
> The problem seems to be that protocol 2 lacks a way to "half close" a
> channel, e.g. close its output while keeping its input open.

yes, there is only an 'EOF' message that means:
  I will not send data over this channel,
but there is no way to say: 
  I'm no longer interested in what you want to send to me.
Comment 8 Damien Miller 2008-05-10 02:30:24 AEST
A fix to this bug has been committed and, barring any problems, will be in OpenSSH 5.1:

> CVSROOT:        /cvs
> Module name:    src
> Changes by:     markus@cvs.openbsd.org  2008/05/09 10:16:06
> 
> Modified files:
>         usr.bin/ssh    : session.c
> 
> Log message:
> re-add the USE_PIPES code and enable it.
> without pipes shutdown-read from the sshd does not trigger
> a SIGPIPE when the forked program does a write.
> 
> ok djm@
> 
> 
> CVSROOT:        /cvs
> Module name:    src
> Changes by:     markus@cvs.openbsd.org  2008/05/09 10:17:51
> 
> Modified files:
>         usr.bin/ssh    : channels.c
> 
> Log message:
> error-fd race: don't enable the error fd in the select bitmask
> for channels with both in- and output closed, since the channel
> will go away before we call select();
> report, lots of debugging help and ok djm@
> 
> 
> CVSROOT:        /cvs
> Module name:    src
> Changes by:     markus@cvs.openbsd.org  2008/05/09 10:21:13
> 
> Modified files:
>         usr.bin/ssh    : channels.h clientloop.c nchan.c serverloop.c
> 
> Log message:
> unbreak
> ssh -2 localhost od /bin/ls | true
> ignoring SIGPIPE by adding a new channel message (EOW) that signals
> the peer that we're not interested in any data it might send.
> fixes bz #85; discussion, debugging and ok djm@
Comment 9 Damien Miller 2008-07-22 12:06:22 AEST
Mass update RESOLVED->CLOSED after release of openssh-5.1