nicolas / debian.moreutils (public) (License: GPL-2, GPL-2+, Expat, BSD-2-Clause, Public Domain) (since 2018-09-25) (hash sha1)
Debian packaging of joeyh's moreutils
List of commits:
Subject Hash Author Date (UTC)
pee: ignore SIGPIPE and write errors (Closes: #697052) 5083c319d130bbf5ef1a071d178f1f30aa049e58 Nicolas Schier 2017-12-31 14:26:35
ts: Added %.T format like %T but with hi-res. 19d1bde3491f737c2d3babd94de0de8eb9d9b1c9 Joey Hess 2017-11-27 21:18:56
make -m start at current time 3d31d550ffc75f7eada0d6cb624a98423b54bbd2 Joey Hess 2017-10-31 17:02:48
document -m c5a0deb4fbca8d95a63374e2b2ef1ac0f87520c1 Joey Hess 2017-10-31 16:58:05
else indent style fix 52e35719dc334da747c543f0da8f2fd0e537b2c6 Joey Hess 2017-10-30 16:51:58
ts: Introduce '-m' option to use CLOCK_MONOTONIC 96809417fcceb13c83caa6b16d8174ea209bce27 Ben Leinweber 2017-10-30 15:24:47
Revert "ts: Introduce '-m' option to use CLOCK_MONOTONIC" b6a010d759c53befdc9755760d28b6647d50f8b0 Joey Hess 2017-10-30 16:50:34
ts: Add -m option to use monotonic clock. Thanks, Ben Leinweber 12845e32adcaa18b83cd8f3f01fddf9189c7ebda Joey Hess 2017-10-30 16:49:36
else indent style fix 5b628493242860cdbec41a23e23bb561c96e4b40 Joey Hess 2017-10-30 16:49:12
ts: Introduce '-m' option to use CLOCK_MONOTONIC d4592ac408f2086a3ed305c3fccf9107763e2be4 Ben Leinweber 2017-10-30 15:24:47
releasing package moreutils version 0.61 01d1b22f22fae647cbfd855dc82f8d9548607ab0 Joey Hess 2017-04-19 14:31:30
chronic: Flush output more often to better preserve stdout,err ordering. 53c35a635276bb78f098947755dd072b5b800358 Joey Hess 2016-10-17 15:49:07
releasing package moreutils version 0.60 1173bd9f10d731485f3b63f1c7ff55eb9c58a605 Joey Hess 2016-08-13 13:58:21
Modify Cygwin check to use findstring instead of uname -o 2d427c09cff6e7666e07c301c4b46c6206362a36 Tony Kelman 2016-08-10 03:23:52
changelog e725f4d1607312a8ed3a5690e2926c26d5c48a61 Joey Hess 2016-07-19 01:03:36
include licence text 29f0d5b620d63de94c066d50e4e468b51037c543 Joey Hess 2016-07-19 01:03:25
add dependency e1a2473fff49f7caee1561bff38ee43ba5a97507 Joey Hess 2016-07-19 01:02:15
Merge is_utf8 from https://github.com/julienpalard/is_utf8. 089fa36ad806246278b43df8dadb9a7882d39e54 Julien Palard 2016-07-18 22:48:55
changelog ccf04c19111b1a2ccae7a16bb07a38a528a34a64 Joey Hess 2016-07-15 20:20:10
cygwin support dee9b5042951795cd7abc415f1c4f4becc6363d3 StalkR 2016-07-15 08:48:35
Commit 5083c319d130bbf5ef1a071d178f1f30aa049e58 - pee: ignore SIGPIPE and write errors (Closes: #697052)
Without ignoring SIGPIPE, any command run by 'pee' that exits early will
close the pipe to 'pee' and thus cause a SIGPIPE that terminates 'pee'.
The more convinient (and possible less surprising) way is probably to
simply ignore the SIGPIPE and let all other commands issued by 'pee'
continue without any harm.

The same argumentation goes for ignoring write errors, as any early
exiting child of 'pee' is closing the pipe and thus causing a write
error.

With this patch examples like

seq 100000 | pee 'head -n1' 'tail -n1'
echo foo | pee cat 'echo bar' cat cat

do output the expected lines, in contrast to

seq 100000 | pee --no-ignore-sigpipe --no-ignore-write-errors 'head -n1' 'tail -n1'
echo foo | pee --no-ignore-sigpipe --no-ignore-write-errors cat 'echo bar' cat cat
.

Thanks to Ole Jørgen Brønner.

Signed-off-by: Nicolas Schier <nicolas@fjasle.eu>
Author: Nicolas Schier
Author date (UTC): 2017-12-31 14:26
Committer name: Joey Hess
Committer date (UTC): 2017-12-31 15:29
Parent(s): 19d1bde3491f737c2d3babd94de0de8eb9d9b1c9
Signing key: DB12DB0FF05F8F38
Tree: e8fba3f62d68ce5384c2098799a9334623c99e51
File Lines added Lines deleted
pee.c 49 4
pee.docbook 41 1
File pee.c changed (mode: 100644) (index a8565c0..9243f4e)
1 1 #include <stdlib.h> #include <stdlib.h>
2 2 #include <stdio.h> #include <stdio.h>
3 #include <string.h>
3 4 #include <sys/types.h> #include <sys/types.h>
4 5 #include <sys/wait.h> #include <sys/wait.h>
5 6
 
... ... close_pipes(FILE **p, size_t i)
28 29
29 30 int int
30 31 main(int argc, char **argv) { main(int argc, char **argv) {
32 int ignore_write_error = 1;
33 int ignore_sigpipe = 1;
31 34 size_t i, r; size_t i, r;
32 35 FILE **pipes; FILE **pipes;
36 int *inactive_pipe;
37 int inactive_pipes = 0;
33 38 char buf[BUFSIZ]; char buf[BUFSIZ];
34 39
40 while(argc > 1) {
41 if (!strcmp(argv[1], "--no-ignore-sigpipe")) {
42 argc--, argv++;
43 ignore_sigpipe = 0;
44 continue;
45 } else if (!strcmp(argv[1], "--ignore-sigpipe")) {
46 argc--, argv++;
47 ignore_sigpipe = 1;
48 continue;
49 } else if (!strcmp(argv[1], "--no-ignore-write-errors")) {
50 argc--, argv++;
51 ignore_write_error = 0;
52 continue;
53 } else if (!strcmp(argv[1], "--ignore-write-errors")) {
54 argc--, argv++;
55 ignore_write_error = 1;
56 continue;
57 }
58 break;
59 }
60
61 if (ignore_sigpipe && (signal(SIGPIPE, SIG_IGN) == SIG_ERR)) {
62 fprintf(stderr, "Unable to ignore SIGPIPE\n");
63 exit(EXIT_FAILURE);
64 }
65
35 66 pipes = malloc(((argc - 1) * sizeof *pipes)); pipes = malloc(((argc - 1) * sizeof *pipes));
36 if (!pipes)
67 inactive_pipe = calloc((argc - 1), (sizeof *inactive_pipe));
68 if (!pipes || !inactive_pipe)
37 69 exit(EXIT_FAILURE); exit(EXIT_FAILURE);
38 70
39 71 for (i = 1; i < argc; i++) { for (i = 1; i < argc; i++) {
 
... ... main(int argc, char **argv) {
46 78 } }
47 79 } }
48 80 argc--; argc--;
49
81
50 82 while(!feof(stdin) && (!ferror(stdin))) { while(!feof(stdin) && (!ferror(stdin))) {
51 83 r = fread(buf, sizeof(char), BUFSIZ, stdin); r = fread(buf, sizeof(char), BUFSIZ, stdin);
52 84 for(i = 0; i < argc; i++) { for(i = 0; i < argc; i++) {
53 if (fwrite(buf, sizeof(char), r, pipes[i]) != r) {
54 fprintf(stderr, "Write error to `%s\'\n", argv[i + 1]);
85 if (inactive_pipe[i])
86 continue;
87
88 if (fwrite(buf, sizeof(char), r, pipes[i]) == r)
89 continue;
90
91 inactive_pipes++;
92
93 if (!ignore_write_error)
94 fprintf(stderr, "Write error to `%s\'\n",
95 argv[i + 1]);
96
97 if (!ignore_write_error || (inactive_pipes == argc)) {
55 98 close_pipes(pipes, argc); close_pipes(pipes, argc);
56 99 exit(EXIT_FAILURE); exit(EXIT_FAILURE);
57 100 } }
101
102 inactive_pipe[i] = 1;
58 103 } }
59 104 } }
60 105 exit(close_pipes(pipes, argc)); exit(close_pipes(pipes, argc));
File pee.docbook changed (mode: 100644) (index f554ad0..4030629)
... ... with this program; if not, write to the Free Software Foundation, Inc.,
33 33 <firstname>Joey</firstname> <firstname>Joey</firstname>
34 34 <surname>Hess</surname> <surname>Hess</surname>
35 35 </author> </author>
36 <date>2006-03-14</date>
36 <date>2016-12-20</date>
37 37 </refentryinfo> </refentryinfo>
38 38
39 39 <refmeta> <refmeta>
 
... ... with this program; if not, write to the Free Software Foundation, Inc.,
51 51 <refsynopsisdiv> <refsynopsisdiv>
52 52 <cmdsynopsis> <cmdsynopsis>
53 53 <command>pee</command> <command>pee</command>
54 <arg>--[no-]ignore-sigpipe</arg>
55 <arg>--[no-]ignore-write-errors</arg>
54 56 <group choice="opt"> <group choice="opt">
55 57 <arg rep="repeat"><replaceable>"command"</replaceable></arg> <arg rep="repeat"><replaceable>"command"</replaceable></arg>
56 58 </group> </group>
 
... ... with this program; if not, write to the Free Software Foundation, Inc.,
70 72 to stdout, like tee does. If that is desired, use to stdout, like tee does. If that is desired, use
71 73 <command>pee cat ...</command></para> <command>pee cat ...</command></para>
72 74 </refsect1> </refsect1>
75
76 <refsect1>
77 <title>OPTIONS</title>
78
79 <variablelist>
80 <varlistentry>
81 <term><option>--ignore-sigpipe</option></term>
82 <term><option>--no-ignore-sigpipe</option></term>
83 <listitem>
84 <para>Do (not) ignore SIGPIPE. Any command started
85 by <command>pee</command> might cause a SIGPIPE
86 when it exists. If you ignore SIGPIPE, you
87 probably also want to ignore write errors (see
88 below). Ignoring SIGPIPE is the default
89 behaviour.</para>
90 </listitem>
91 </varlistentry>
92
93 <varlistentry>
94 <term><option>--ignore-write-errors</option></term>
95 <term><option>--no-ignore-write-errors</option></term>
96 <listitem>
97 <para>Do (not) ignore write errors. When a command
98 started by <command>pee</command> is no more
99 accepting data via the pipe between itself and
100 <command>pee</command>, a write error occurs in
101 <command>pee</command>. If this error is not
102 ignored, <command>pee</command> is going to
103 terminate all child processes and exists. Ignoring
104 write errors is the default behaviour.</para>
105 </listitem>
106 </varlistentry>
107
108 </variablelist>
109 </refsect1>
73 110
74 111 <refsect1> <refsect1>
75 112 <title>SEE ALSO</title> <title>SEE ALSO</title>
 
... ... with this program; if not, write to the Free Software Foundation, Inc.,
77 114 <para> <para>
78 115 <citerefentry> <citerefentry>
79 116 <refentrytitle>tee</refentrytitle><manvolnum>1</manvolnum> <refentrytitle>tee</refentrytitle><manvolnum>1</manvolnum>
117 </citerefentry>,
118 <citerefentry>
119 <refentrytitle>pipe</refentrytitle><manvolnum>7</manvolnum>
80 120 </citerefentry> </citerefentry>
81 121 </para> </para>
82 122
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/nicolas/debian.moreutils

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/nicolas/debian.moreutils

Clone this repository using git:
git clone git://git.rocketgit.com/user/nicolas/debian.moreutils

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main