OpenSSH 2.3.0p1: Broken pipe / SIGPIPE
Damien Miller
djm at mindrot.org
Wed Dec 13 10:25:18 EST 2000
On Tue, 12 Dec 2000, Rachit Siamwalla wrote:
Does this patch help?
Index: session.c
===================================================================
RCS file: /cvs/openssh_cvs/session.c,v
retrieving revision 1.58
diff -u -r1.58 session.c
--- session.c 2000/11/29 04:55:17 1.58
+++ session.c 2000/12/12 23:24:37
@@ -480,8 +480,6 @@
if (s == NULL)
fatal("do_exec_no_pty: no session");
- signal(SIGPIPE, SIG_DFL);
-
session_proctitle(s);
#ifdef USE_PAM
@@ -493,6 +491,8 @@
/* Child. Reinitialize the log since the pid has changed. */
log_init(__progname, options.log_level, options.log_facility, log_stderr);
+ signal(SIGPIPE, SIG_DFL);
+
/*
* Create a new session and process group since the 4.4BSD
* setlogin() affects the entire process group.
@@ -605,6 +605,8 @@
if ((pid = fork()) == 0) {
/* Child. Reinitialize the log because the pid has changed. */
log_init(__progname, options.log_level, options.log_facility, log_stderr);
+
+ signal(SIGPIPE, SIG_DFL);
/* Close the master side of the pseudo tty. */
close(ptyfd);
> I believe this is normal behavior. Try it without using SSH, and it will
> happen.
>
> Basically it happens if the command on the right hand side of the pipe
> exits (normally or abnormally) before the command on the left of the
> pipe finishes writing its output. The fd will be closed and thus the
> process on the left will get a SIGPIPE (or pipe write error if its
> masked out).
>
> -rchit
>
> > "yes | head -1" says "Broken pipe".
> > Another example is to call something like "grep foobar file | less"
> > on a file with thousands of occurences of "foobar". After "less"
> > has displayed the first page, if I then hit "q" (for quit), I get
> > thousands of lines saying:
> >
> > grep: writing output: Broken pipe
> >
>
--
| ``We've all heard that a million monkeys banging on | Damien Miller -
| a million typewriters will eventually reproduce the | <djm at mindrot.org>
| works of Shakespeare. Now, thanks to the Internet, /
| we know this is not true.'' - Robert Wilensky UCB / http://www.mindrot.org
More information about the openssh-unix-dev
mailing list