From unknown Sat Aug 16 16:57:14 2025 X-Loop: help-debbugs@gnu.org Subject: bug#11540: [PATCH] tee: add a flag to ignore SIGPIPE Resent-From: Igor Ippolitov Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-coreutils@gnu.org Resent-Date: Tue, 22 May 2012 16:19:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 11540 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: patch To: 11540@debbugs.gnu.org X-Debbugs-Original-To: bug-coreutils@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.133770348820534 (code B ref -1); Tue, 22 May 2012 16:19:01 +0000 Received: (at submit) by debbugs.gnu.org; 22 May 2012 16:18:08 +0000 Received: from localhost ([127.0.0.1]:39086 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SWrmP-0005KY-Ei for submit@debbugs.gnu.org; Tue, 22 May 2012 12:18:08 -0400 Received: from eggs.gnu.org ([208.118.235.92]:51373) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SWpeo-00020a-5A for submit@debbugs.gnu.org; Tue, 22 May 2012 10:01:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SWpdu-00058E-SL for submit@debbugs.gnu.org; Tue, 22 May 2012 10:01:01 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.2 Received: from lists.gnu.org ([208.118.235.17]:32925) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SWpdu-00058A-MX for submit@debbugs.gnu.org; Tue, 22 May 2012 10:00:54 -0400 Received: from eggs.gnu.org ([208.118.235.92]:50375) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SWpdp-0004EJ-Oh for bug-coreutils@gnu.org; Tue, 22 May 2012 10:00:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SWpdi-00053J-HJ for bug-coreutils@gnu.org; Tue, 22 May 2012 10:00:49 -0400 Received: from mail-qc0-f169.google.com ([209.85.216.169]:47199) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SWpdi-00052z-5k for bug-coreutils@gnu.org; Tue, 22 May 2012 10:00:42 -0400 Received: by qcsd16 with SMTP id d16so4761830qcs.0 for ; Tue, 22 May 2012 07:00:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=0GxgB16nRjy9zP2/W/HgkLolv+TkbQYZVZsLdv9vM0Q=; b=PyG40rZ/Njz/oHY3Z79ltSHdAxLtD05V3VF9S1Sk6fmkxUitBIr0IOZkh2sxjfb3oH z3klfuepivYG95bE1fChPJWpWCG6Jb9lwgMJxfMreGn6z//cZzV7j+8+HGihB3C7Hewy 8+c0DO4G6KWUVrHN6GQL1kzOIlXXsRL5FqZt/ZvRx8BWFx5Tsf8kvoQfzPEsg58sviqV DhFbCrQnBV5557WFDDKV27UCLpmEp6hm7f5If+rz3mr+TxuIlNWUnHEUK3HpLqcgZj6U HKOFSzhLCndlZ3DPwE7jVSPDiy/EBpiaGTEsj6Fovq58TrH5n3yqUYo+ZT1FYu+EiSag RNiw== MIME-Version: 1.0 Received: by 10.60.3.34 with SMTP id 2mr4363801oez.27.1337695239476; Tue, 22 May 2012 07:00:39 -0700 (PDT) Received: by 10.60.47.102 with HTTP; Tue, 22 May 2012 07:00:39 -0700 (PDT) Date: Tue, 22 May 2012 18:00:39 +0400 Message-ID: From: Igor Ippolitov Content-Type: multipart/alternative; boundary=e89a8fb1ff049117f804c0a07148 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 208.118.235.17 X-Spam-Score: -6.1 (------) X-Mailman-Approved-At: Tue, 22 May 2012 12:17:47 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.1 (------) --e89a8fb1ff049117f804c0a07148 Content-Type: text/plain; charset=ISO-8859-1 >From 89c055b385a9d4f4804af6b7b3fbe67651471613 Mon Sep 17 00:00:00 2001 From: Ippolitov A. Igor Date: Tue, 22 May 2012 17:58:23 +0400 Subject: [PATCH] tee: add a flag to ignore SIGPIPE * src/tee.c: added ignore_sigpipes variable and -p and --ignore-sigpipes options If we call tee like: program | tee file1 file2 | head -3 just to be sure there some output from program started. Or like: program | tee >(head -1) file1 file2 We'll get SIGPIPE on writing to a file. It can be undesirable behaviour: file1 and file2 would be incomplete. Running with -i won't correct this. "-p|--ignore-sigpipes" options will make tee ignore any sigpipe it can receive. So file1 and file2 would have complete output. --- src/tee.c | 19 ++++++++++++++++++- 1 files changed, 18 insertions(+), 1 deletions(-) diff --git a/src/tee.c b/src/tee.c index 2d82577..0021174 100644 --- a/src/tee.c +++ b/src/tee.c @@ -43,10 +43,14 @@ static bool append; /* If true, ignore interrupts. */ static bool ignore_interrupts; +/* if true, ignore sigpipe signal. */ +static bool ignore_sigpipes; + static struct option const long_options[] = { {"append", no_argument, NULL, 'a'}, {"ignore-interrupts", no_argument, NULL, 'i'}, + {"ignore-sigpipes", no_argument, NULL, 'p'}, {GETOPT_HELP_OPTION_DECL}, {GETOPT_VERSION_OPTION_DECL}, {NULL, 0, NULL, 0} @@ -65,6 +69,7 @@ Copy standard input to each FILE, and also to standard output.\n\ \n\ -a, --append append to the given FILEs, do not overwrite\n\ -i, --ignore-interrupts ignore interrupt signals\n\ + -p, --ignore-sigpipe ignore pipe signals\n\ "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); @@ -93,8 +98,9 @@ main (int argc, char **argv) append = false; ignore_interrupts = false; + ignore_sigpipes = false; - while ((optc = getopt_long (argc, argv, "ai", long_options, NULL)) != -1) + while ((optc = getopt_long (argc, argv, "aip", long_options, NULL)) != -1) { switch (optc) { @@ -106,6 +112,10 @@ main (int argc, char **argv) ignore_interrupts = true; break; + case 'p': + ignore_sigpipes = true; + break; + case_GETOPT_HELP_CHAR; case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); @@ -116,7 +126,14 @@ main (int argc, char **argv) } if (ignore_interrupts) + { signal (SIGINT, SIG_IGN); + } + + if (ignore_sigpipes) + { + signal (SIGPIPE, SIG_IGN); + } /* Do *not* warn if tee is given no file arguments. POSIX requires that it work when given no arguments. */ -- 1.7.0.4 --e89a8fb1ff049117f804c0a07148 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable >From 89c055b385a9d4f4804af6b7b3fbe67651471613 Mon Sep 17 00:00:00 2001
F= rom: Ippolitov A. Igor <iippolit= ov@gmail.com>
Date: Tue, 22 May 2012 17:58:23 +0400
Subject: [= PATCH] tee: add a flag to ignore SIGPIPE

* src/tee.c: added ignore_sigpipes variable and -p
=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0 and --ignore-sigpipes options

If we call tee l= ike:
program | tee file1 file2 | head -3
just to be sure there some o= utput from program started. Or like:
program | tee >(head -1) file1 file2
We'll get SIGPIPE on writing= to a file. It can be undesirable
behaviour: file1 and file2 would be in= complete.
Running with -i won't correct this.
"-p|--ignore-s= igpipes" options will make tee ignore any sigpipe
it can receive. So file1 and file2 would have complete output.
---
= =A0src/tee.c |=A0=A0 19 ++++++++++++++++++-
=A01 files changed, 18 inser= tions(+), 1 deletions(-)

diff --git a/src/tee.c b/src/tee.c
index= 2d82577..0021174 100644
--- a/src/tee.c
+++ b/src/tee.c
@@ -43,10 +43,14 @@ static bool appen= d;
=A0/* If true, ignore interrupts. */
=A0static bool ignore_interru= pts;
=A0
+/* if true, ignore sigpipe signal. */
+static bool ignor= e_sigpipes;
+
=A0static struct option const long_options[] =3D
=A0{
=A0=A0 {&q= uot;append", no_argument, NULL, 'a'},
=A0=A0 {"ignore-= interrupts", no_argument, NULL, 'i'},
+=A0 {"ignore-si= gpipes", no_argument, NULL, 'p'},
=A0=A0 {GETOPT_HELP_OPTION_DECL},
=A0=A0 {GETOPT_VERSION_OPTION_DECL},=A0=A0 {NULL, 0, NULL, 0}
@@ -65,6 +69,7 @@ Copy standard input to eac= h FILE, and also to standard output.\n\
=A0\n\
=A0=A0 -a, --append=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 append to the given FILEs, do not over= write\n\
=A0=A0 -i, --ignore-interrupts=A0=A0 ignore interrupt signals\n\
+=A0 -p= , --ignore-sigpipe=A0=A0=A0=A0=A0 ignore pipe signals\n\
=A0"), std= out);
=A0=A0=A0=A0=A0=A0 fputs (HELP_OPTION_DESCRIPTION, stdout);
=A0= =A0=A0=A0=A0=A0 fputs (VERSION_OPTION_DESCRIPTION, stdout);
@@ -93,8 +98,9 @@ main (int argc, char **argv)
=A0
=A0=A0 append =3D = false;
=A0=A0 ignore_interrupts =3D false;
+=A0 ignore_sigpipes =3D f= alse;
=A0
-=A0 while ((optc =3D getopt_long (argc, argv, "ai&quo= t;, long_options, NULL)) !=3D -1)
+=A0 while ((optc =3D getopt_long (argc, argv, "aip", long_option= s, NULL)) !=3D -1)
=A0=A0=A0=A0 {
=A0=A0=A0=A0=A0=A0 switch (optc)=A0=A0=A0=A0=A0=A0=A0=A0 {
@@ -106,6 +112,10 @@ main (int argc, char **= argv)
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 ignore_interrupts =3D true;
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 break;
=A0
+=A0=A0=A0=A0=A0=A0=A0 case= 'p':
+=A0=A0=A0=A0=A0=A0=A0=A0=A0 ignore_sigpipes =3D true;
= +=A0=A0=A0=A0=A0=A0=A0=A0=A0 break;
+
=A0=A0=A0=A0=A0=A0=A0=A0 case_G= ETOPT_HELP_CHAR;
=A0
=A0=A0=A0=A0=A0=A0=A0=A0 case_GETOPT_VERSION_CHA= R (PROGRAM_NAME, AUTHORS);
@@ -116,7 +126,14 @@ main (int argc, char **argv)
=A0=A0=A0=A0 }
=A0<= br>=A0=A0 if (ignore_interrupts)
+=A0=A0=A0 {
=A0=A0=A0=A0 signal (SI= GINT, SIG_IGN);
+=A0=A0=A0 }
+
+=A0 if (ignore_sigpipes)
+=A0= =A0=A0 {
+=A0=A0=A0 signal (SIGPIPE, SIG_IGN);
+=A0=A0=A0 }
=A0
=A0=A0 /* Do *not* warn if tee is given no file argu= ments.
=A0=A0=A0=A0=A0 POSIX requires that it work when given no argumen= ts.=A0 */
--
1.7.0.4

--e89a8fb1ff049117f804c0a07148-- From unknown Sat Aug 16 16:57:14 2025 X-Loop: help-debbugs@gnu.org Subject: bug#11540: [PATCH] tee: add a flag to ignore SIGPIPE Resent-From: =?UTF-8?Q?P=C3=A1draig?= Brady Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-coreutils@gnu.org Resent-Date: Tue, 22 May 2012 17:20:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 11540 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: patch To: Igor Ippolitov Cc: 11540@debbugs.gnu.org, Bruno Haible Received: via spool by 11540-submit@debbugs.gnu.org id=B11540.133770716826313 (code B ref 11540); Tue, 22 May 2012 17:20:02 +0000 Received: (at 11540) by debbugs.gnu.org; 22 May 2012 17:19:28 +0000 Received: from localhost ([127.0.0.1]:39201 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SWsk4-0006qK-77 for submit@debbugs.gnu.org; Tue, 22 May 2012 13:19:28 -0400 Received: from mail2.vodafone.ie ([213.233.128.44]:65225) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SWsk1-0006q5-4Y for 11540@debbugs.gnu.org; Tue, 22 May 2012 13:19:27 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApMBAFC/u09tTAos/2dsb2JhbAANN7cuAQEBBAECLwFGEAsNAQMDAQIBCRYPCQMCAQIBDwcnCAYNAQUCAQGHfAMWsDwNiVKKGm6FPQOSd1eCXYRihQaHZA Received: from unknown (HELO [192.168.1.79]) ([109.76.10.44]) by mail2.vodafone.ie with ESMTP; 22 May 2012 18:18:31 +0100 Message-ID: <4FBBCA67.1090006@draigBrady.com> Date: Tue, 22 May 2012 18:18:31 +0100 From: =?UTF-8?Q?P=C3=A1draig?= Brady User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:6.0) Gecko/20110816 Thunderbird/6.0 MIME-Version: 1.0 References: In-Reply-To: X-Enigmail-Version: 1.3.2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Spam-Score: -1.9 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) On 05/22/2012 03:00 PM, Igor Ippolitov wrote: >>>From 89c055b385a9d4f4804af6b7b3fbe67651471613 Mon Sep 17 00:00:00 2001 > From: Ippolitov A. Igor > Date: Tue, 22 May 2012 17:58:23 +0400 > Subject: [PATCH] tee: add a flag to ignore SIGPIPE > > * src/tee.c: added ignore_sigpipes variable and -p > and --ignore-sigpipes options > > If we call tee like: > program | tee file1 file2 | head -3 > just to be sure there some output from program started. Or like: > program | tee >(head -1) file1 file2 > We'll get SIGPIPE on writing to a file. It can be undesirable > behaviour: file1 and file2 would be incomplete. > Running with -i won't correct this. > "-p|--ignore-sigpipes" options will make tee ignore any sigpipe > it can receive. So file1 and file2 would have complete output. > --- > src/tee.c | 19 ++++++++++++++++++- > 1 files changed, 18 insertions(+), 1 deletions(-) > > diff --git a/src/tee.c b/src/tee.c > index 2d82577..0021174 100644 > --- a/src/tee.c > +++ b/src/tee.c > @@ -43,10 +43,14 @@ static bool append; > /* If true, ignore interrupts. */ > static bool ignore_interrupts; > > +/* if true, ignore sigpipe signal. */ > +static bool ignore_sigpipes; > + > static struct option const long_options[] = > { > {"append", no_argument, NULL, 'a'}, > {"ignore-interrupts", no_argument, NULL, 'i'}, > + {"ignore-sigpipes", no_argument, NULL, 'p'}, > {GETOPT_HELP_OPTION_DECL}, > {GETOPT_VERSION_OPTION_DECL}, > {NULL, 0, NULL, 0} > @@ -65,6 +69,7 @@ Copy standard input to each FILE, and also to standard > output.\n\ > \n\ > -a, --append append to the given FILEs, do not overwrite\n\ > -i, --ignore-interrupts ignore interrupt signals\n\ > + -p, --ignore-sigpipe ignore pipe signals\n\ > "), stdout); > fputs (HELP_OPTION_DESCRIPTION, stdout); > fputs (VERSION_OPTION_DESCRIPTION, stdout); > @@ -93,8 +98,9 @@ main (int argc, char **argv) > > append = false; > ignore_interrupts = false; > + ignore_sigpipes = false; > > - while ((optc = getopt_long (argc, argv, "ai", long_options, NULL)) != -1) > + while ((optc = getopt_long (argc, argv, "aip", long_options, NULL)) != > -1) > { > switch (optc) > { > @@ -106,6 +112,10 @@ main (int argc, char **argv) > ignore_interrupts = true; > break; > > + case 'p': > + ignore_sigpipes = true; > + break; > + > case_GETOPT_HELP_CHAR; > > case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); > @@ -116,7 +126,14 @@ main (int argc, char **argv) > } > > if (ignore_interrupts) > + { > signal (SIGINT, SIG_IGN); > + } > + > + if (ignore_sigpipes) > + { > + signal (SIGPIPE, SIG_IGN); > + } > > /* Do *not* warn if tee is given no file arguments. > POSIX requires that it work when given no arguments. */ I checked back and there was a very similar patch nearly 4 years ago. http://lists.gnu.org/archive/html/bug-coreutils/2008-10/msg00067.html I think there was general agreement in the thread on its merits. I wonder though, would a higher level option be more appropriate? I think what's being configured here is whether to exit early on write error, whether it is to one of the files or stdout. Why would you want to treat them differently? Also you could get SIGPIPEs I think if one of the files was >(a process). The default would be to diagnose write errors, and that could be changed with: --write-error={[cont],ignore,exit} cheers, Pádraig. From unknown Sat Aug 16 16:57:14 2025 X-Loop: help-debbugs@gnu.org Subject: bug#11540: [PATCH] tee: add a flag to ignore SIGPIPE Resent-From: =?UTF-8?Q?P=C3=A1draig?= Brady Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-coreutils@gnu.org Resent-Date: Tue, 22 May 2012 17:34:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 11540 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: patch To: Igor Ippolitov Cc: 11540@debbugs.gnu.org, Bruno Haible , Jann horn Received: via spool by 11540-submit@debbugs.gnu.org id=B11540.133770803427598 (code B ref 11540); Tue, 22 May 2012 17:34:01 +0000 Received: (at 11540) by debbugs.gnu.org; 22 May 2012 17:33:54 +0000 Received: from localhost ([127.0.0.1]:39206 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SWsy1-0007B5-TI for submit@debbugs.gnu.org; Tue, 22 May 2012 13:33:54 -0400 Received: from mail2.vodafone.ie ([213.233.128.44]:39967) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SWsxg-0007AY-Ov for 11540@debbugs.gnu.org; Tue, 22 May 2012 13:33:51 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApMBAHjAu09tTAos/2dsb2JhbAANN7cuAQEBBAECLwFGEAsNAQMDAQIBCRYPCQMCAQIBDwcnCAYNAQUCAQGHfAMWsD4NiVKKGm6FPQOSd1eCXYRihQaHZA Received: from unknown (HELO [192.168.1.79]) ([109.76.10.44]) by mail2.vodafone.ie with ESMTP; 22 May 2012 18:32:42 +0100 Message-ID: <4FBBCDB9.1020306@draigBrady.com> Date: Tue, 22 May 2012 18:32:41 +0100 From: =?UTF-8?Q?P=C3=A1draig?= Brady User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:6.0) Gecko/20110816 Thunderbird/6.0 MIME-Version: 1.0 References: <4FBBCA67.1090006@draigBrady.com> In-Reply-To: <4FBBCA67.1090006@draigBrady.com> X-Enigmail-Version: 1.3.2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Spam-Score: -1.9 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) On 05/22/2012 06:18 PM, Pádraig Brady wrote: > On 05/22/2012 03:00 PM, Igor Ippolitov wrote: >> >From 89c055b385a9d4f4804af6b7b3fbe67651471613 Mon Sep 17 00:00:00 2001 >> From: Ippolitov A. Igor >> Date: Tue, 22 May 2012 17:58:23 +0400 >> Subject: [PATCH] tee: add a flag to ignore SIGPIPE >> >> * src/tee.c: added ignore_sigpipes variable and -p >> and --ignore-sigpipes options >> >> If we call tee like: >> program | tee file1 file2 | head -3 >> just to be sure there some output from program started. Or like: >> program | tee >(head -1) file1 file2 >> We'll get SIGPIPE on writing to a file. It can be undesirable >> behaviour: file1 and file2 would be incomplete. >> Running with -i won't correct this. >> "-p|--ignore-sigpipes" options will make tee ignore any sigpipe >> it can receive. So file1 and file2 would have complete output. > > >> --- >> src/tee.c | 19 ++++++++++++++++++- >> 1 files changed, 18 insertions(+), 1 deletions(-) >> >> diff --git a/src/tee.c b/src/tee.c >> index 2d82577..0021174 100644 >> --- a/src/tee.c >> +++ b/src/tee.c >> @@ -43,10 +43,14 @@ static bool append; >> /* If true, ignore interrupts. */ >> static bool ignore_interrupts; >> >> +/* if true, ignore sigpipe signal. */ >> +static bool ignore_sigpipes; >> + >> static struct option const long_options[] = >> { >> {"append", no_argument, NULL, 'a'}, >> {"ignore-interrupts", no_argument, NULL, 'i'}, >> + {"ignore-sigpipes", no_argument, NULL, 'p'}, >> {GETOPT_HELP_OPTION_DECL}, >> {GETOPT_VERSION_OPTION_DECL}, >> {NULL, 0, NULL, 0} >> @@ -65,6 +69,7 @@ Copy standard input to each FILE, and also to standard >> output.\n\ >> \n\ >> -a, --append append to the given FILEs, do not overwrite\n\ >> -i, --ignore-interrupts ignore interrupt signals\n\ >> + -p, --ignore-sigpipe ignore pipe signals\n\ >> "), stdout); >> fputs (HELP_OPTION_DESCRIPTION, stdout); >> fputs (VERSION_OPTION_DESCRIPTION, stdout); >> @@ -93,8 +98,9 @@ main (int argc, char **argv) >> >> append = false; >> ignore_interrupts = false; >> + ignore_sigpipes = false; >> >> - while ((optc = getopt_long (argc, argv, "ai", long_options, NULL)) != -1) >> + while ((optc = getopt_long (argc, argv, "aip", long_options, NULL)) != >> -1) >> { >> switch (optc) >> { >> @@ -106,6 +112,10 @@ main (int argc, char **argv) >> ignore_interrupts = true; >> break; >> >> + case 'p': >> + ignore_sigpipes = true; >> + break; >> + >> case_GETOPT_HELP_CHAR; >> >> case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); >> @@ -116,7 +126,14 @@ main (int argc, char **argv) >> } >> >> if (ignore_interrupts) >> + { >> signal (SIGINT, SIG_IGN); >> + } >> + >> + if (ignore_sigpipes) >> + { >> + signal (SIGPIPE, SIG_IGN); >> + } >> >> /* Do *not* warn if tee is given no file arguments. >> POSIX requires that it work when given no arguments. */ > > > I checked back and there was a very similar patch nearly 4 years ago. > http://lists.gnu.org/archive/html/bug-coreutils/2008-10/msg00067.html > I think there was general agreement in the thread on its merits. > > I wonder though, would a higher level option be more appropriate? > I think what's being configured here is whether to exit early on write error, > whether it is to one of the files or stdout. Why would you want > to treat them differently? Also you could get SIGPIPEs I think > if one of the files was >(a process). > > The default would be to diagnose write errors, > and that could be changed with: > > --write-error={[cont],ignore,exit} I just looked at a recent proposal that overlaps with the above nicely: http://lists.gnu.org/archive/html/coreutils/2012-05/msg00070.html cheers, Pádraig. From unknown Sat Aug 16 16:57:14 2025 X-Loop: help-debbugs@gnu.org Subject: bug#11540: [PATCH] tee: add a flag to ignore SIGPIPE Resent-From: Igor Ippolitov Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-coreutils@gnu.org Resent-Date: Wed, 23 May 2012 13:27:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 11540 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: patch To: =?UTF-8?Q?P=C3=A1draig?= Brady Cc: 11540@debbugs.gnu.org, Bruno Haible Received: via spool by 11540-submit@debbugs.gnu.org id=B11540.133777957912950 (code B ref 11540); Wed, 23 May 2012 13:27:02 +0000 Received: (at 11540) by debbugs.gnu.org; 23 May 2012 13:26:19 +0000 Received: from localhost ([127.0.0.1]:40480 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SXBZy-0003Mo-44 for submit@debbugs.gnu.org; Wed, 23 May 2012 09:26:18 -0400 Received: from mail-ob0-f172.google.com ([209.85.214.172]:52266) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SXBZu-0003Ma-T7 for 11540@debbugs.gnu.org; Wed, 23 May 2012 09:26:16 -0400 Received: by obbeh20 with SMTP id eh20so11277260obb.3 for <11540@debbugs.gnu.org>; Wed, 23 May 2012 06:25:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=4BEoEpNzWCQQOvT0/F46C26Ut/Rpd35CxeW+S3m6vh4=; b=WBHTQIBY3qdCixXZDaRP8ErwVoDYKN8RMe0orQ/J9UpXIZEM12+Q/78t4U31dNa7U5 Umv25uY6xKchdT/uofenz0TWAjJhPDxIv4OQnXA54BI4rc3AbUEPK3OlWzUUNEbOnGpy 9JesSvobCoJ/2r/b5+Fr1/d9Z6eX03Lhdg//usursTTMKquzY2K0JF4K0trDdwVHfeha VZZrJ2zhw9Y1BbAp7ICYYJDhzfWwrr5Fwr0IKNC0Sq6DNnN2Ptt6T4hJ01urB2Lw/00C j9OBFMsAbTSknaHDPjN4QzY4Buv9vd5cHIcB+uaqcIT1CzpDngAT5oigijm0q8J7nf/7 XtVw== MIME-Version: 1.0 Received: by 10.182.14.100 with SMTP id o4mr26441416obc.23.1337779517943; Wed, 23 May 2012 06:25:17 -0700 (PDT) Received: by 10.60.47.102 with HTTP; Wed, 23 May 2012 06:25:17 -0700 (PDT) In-Reply-To: <4FBBCA67.1090006@draigBrady.com> References: <4FBBCA67.1090006@draigBrady.com> Date: Wed, 23 May 2012 17:25:17 +0400 Message-ID: From: Igor Ippolitov Content-Type: multipart/alternative; boundary=14dae9399bb5f470a904c0b41038 X-Spam-Score: -2.6 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.6 (--) --14dae9399bb5f470a904c0b41038 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 2012/5/22 P=E1draig Brady > > I checked back and there was a very similar patch nearly 4 years ago. > http://lists.gnu.org/archive/html/bug-coreutils/2008-10/msg00067.html > I think there was general agreement in the thread on its merits. > > I wonder though, would a higher level option be more appropriate? > I think what's being configured here is whether to exit early on write > error, > whether it is to one of the files or stdout. Why would you want > to treat them differently? Also you could get SIGPIPEs I think > if one of the files was >(a process). > > The default would be to diagnose write errors, > and that could be changed with: > > --write-error=3D{[cont],ignore,exit} > > cheers, > P=E1draig. > I can write a patch that would let you choose, what to do on write errors. Currently, I can't understand, why previous patch (in thread you pointed out) is not in tee. I'm not familiar with POSIX, so I appreciate any guidance in what should I do next. What should I read and implement to make tee continuing writing files faster receiving error on writing to a pipe? --14dae9399bb5f470a904c0b41038 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable

2012/5/22 P=E1draig Brady <P@draigbrady.= com>

I checked back and there was a very similar patch nearly 4 years ago.
http://lists.gnu.org/archive/html/bug-coreutils/20= 08-10/msg00067.html
I think there was general agreement in the thread on its merits.

I wonder though, would a higher level option be more appropriate?
I think what's being configured here is whether to exit early on write = error,
whether it is to one of the files or stdout. Why would you want
to treat them differently? Also you could get SIGPIPEs I think
if one of the files was >(a process).

The default would be to diagnose write errors,
and that could be changed with:

--write-error=3D{[cont],ignore,exit}

cheers,
P=E1draig.


I can write a patch that would let = you choose, what to do on write errors.

Currently, I can't unde= rstand, why previous patch (in thread you pointed out) is not in tee.
I'm not familiar with POSIX, so I appreciate any guidance in what shoul= d I do next. What should I read and implement to make tee continuing writin= g files faster receiving error on writing to a pipe?
--14dae9399bb5f470a904c0b41038-- From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 26 15:39:18 2014 Received: (at control) by debbugs.gnu.org; 26 Sep 2014 19:39:18 +0000 Received: from localhost ([127.0.0.1]:53321 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XXbML-0001XD-TI for submit@debbugs.gnu.org; Fri, 26 Sep 2014 15:39:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59757) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XXbMJ-0001X5-Gn for control@debbugs.gnu.org; Fri, 26 Sep 2014 15:39:16 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s8QJdDvs019059 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Fri, 26 Sep 2014 15:39:14 -0400 Received: from [10.36.116.33] (ovpn-116-33.ams2.redhat.com [10.36.116.33]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s8QJdBke017606 (version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO) for ; Fri, 26 Sep 2014 15:39:12 -0400 Message-ID: <5425C0DE.3010002@draigBrady.com> Date: Fri, 26 Sep 2014 20:39:10 +0100 From: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: GNU bug tracker automated control server X-Enigmail-Version: 1.6 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Spam-Score: -3.0 (---) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.0 (---) unarchive 11540 forcemerge 11540 18567 stop From unknown Sat Aug 16 16:57:14 2025 X-Loop: help-debbugs@gnu.org Subject: bug#11540: [PATCH] tee: add a flag to ignore SIGPIPE Resent-From: Assaf Gordon Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Tue, 09 Oct 2018 21:17:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 11540 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: patch To: Igor Ippolitov , =?UTF-8?Q?P=C3=A1draig?= Brady Cc: 11540@debbugs.gnu.org, Bruno Haible Received: via spool by 11540-submit@debbugs.gnu.org id=B11540.15391197919070 (code B ref 11540); Tue, 09 Oct 2018 21:17:01 +0000 Received: (at 11540) by debbugs.gnu.org; 9 Oct 2018 21:16:31 +0000 Received: from localhost ([127.0.0.1]:42650 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1g9zMl-0002Lv-1W for submit@debbugs.gnu.org; Tue, 09 Oct 2018 17:16:31 -0400 Received: from mail-it1-f193.google.com ([209.85.166.193]:38668) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1g9zMj-0002Gt-FK; Tue, 09 Oct 2018 17:16:29 -0400 Received: by mail-it1-f193.google.com with SMTP id i76-v6so4972483ita.3; Tue, 09 Oct 2018 14:16:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=S3LTkoCWGkVS/Un+i6aWEhVY6mEAy/MFNI2OMl152Z4=; b=WSWNRVpPLrrXm/YDVGVdolNu99Ti6gG4TFPNwTQ0JPd5XMHgCqt9JOLgolCjWnVjQK h+7Uc9exgG05LAu86GunTbWwjTYa5L9YTtTSuVh0cyhzFDVPTEqNuNtJNRV1mI6jN24f lR3MzpuNIsF5Uqwd96QJGJcSWB0nE4lY9mdZmTXp7K26o9uG6yYbQd9Z7dbI8QLMb1HX HVGewV7P0UOW2SJ8f7ekiHc3ROhQw80RlMYbF+VLSJnpwrnrP4fsu3d4CmIXdjkVMOJG mjEjNvN82ljeHEMIEVPSAYjIlEaMZthIVbhQ1+NV2zDJCpgUYB0+bhUl3Qnglho/Aos7 qVQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=S3LTkoCWGkVS/Un+i6aWEhVY6mEAy/MFNI2OMl152Z4=; b=ojpWBkZGVjredKvEkzfO7X7ml7Uf40Hk8qjYCrA7dQXxHrobZHsWSs9jf+HYs9b0sM BDpdUgHBzozz+bJlJBGGbITeM+da79NegWXidEK1ceGWKfMoQVgxja0KG3D2fgUDZcAd uHZnUjafUVyODCHsTRlcnUDBnvt0wW+I3VuH4sPgcO/jxWCL2GdD5KRvlVa7b3pbMgPa iWabDcjPvJ6aBZ0iYDGrZslKw7+vLUJ6JwU8Onqw5uY3clEF600CEkeG/bjY+WrUto8E msjEQoLSD1saKhfKOZ+xYnr3Nx9PgnXMVwPnAX7/G+y9zM70PGfPDO0/jqWR/QFRJ7fV okww== X-Gm-Message-State: ABuFfohDMAHTQM6NFgz2HUqwHaEcx4KGxE6eyNvewIMnTaVZCcQdwWd4 8dqRf7yeKE7zo4Rk0hN3EkDri/MPvh8= X-Google-Smtp-Source: ACcGV639IjH1zhcElIVBL8QxG57diGy5cVa//ODLXELPuUYTMytiL5Y7nyKxXMCHZ+nBBA/2eso2Hw== X-Received: by 2002:a24:b047:: with SMTP id b7-v6mr2737284itj.87.1539119783505; Tue, 09 Oct 2018 14:16:23 -0700 (PDT) Received: from tomato.housegordon.com (moose.housegordon.com. [184.68.105.38]) by smtp.googlemail.com with ESMTPSA id j19-v6sm8045391itb.25.2018.10.09.14.16.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Oct 2018 14:16:22 -0700 (PDT) References: <4FBBCA67.1090006@draigBrady.com> From: Assaf Gordon Message-ID: Date: Tue, 9 Oct 2018 15:16:20 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Score: -0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) tags 11540 fixed close 11540 stop (Triaging old bugs) Hello, On 23/05/12 07:25 AM, Igor Ippolitov wrote: >> >> The default would be to diagnose write errors, >> and that could be changed with: >> >> --write-error={[cont],ignore,exit} >> In coreutils version 8.24 (released 2015) 'tee' gained the '--output-error=MODE' option. I'm marking this as "fixed" and closing. regards, - assaf