1 Return-Path: <too@guru.guru-group.fi>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 765EB429E54
\r
6 for <notmuch@notmuchmail.org>; Sun, 1 Apr 2012 11:28:47 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id Yp9cGc0CS2Z6 for <notmuch@notmuchmail.org>;
\r
16 Sun, 1 Apr 2012 11:28:46 -0700 (PDT)
\r
17 Received: from guru.guru-group.fi (guru-group.fi [87.108.86.66])
\r
18 by olra.theworths.org (Postfix) with ESMTP id 578CF431FAF
\r
19 for <notmuch@notmuchmail.org>; Sun, 1 Apr 2012 11:28:46 -0700 (PDT)
\r
20 Received: by guru.guru-group.fi (Postfix, from userid 501)
\r
21 id 1AB9668055; Sun, 1 Apr 2012 21:28:44 +0300 (EEST)
\r
22 From: Tomi Ollila <tomi.ollila@iki.fi>
\r
23 To: notmuch@notmuchmail.org
\r
24 Subject: [PATCH] nmbug: check whether every forked process exit with (non)zero
\r
26 Date: Sun, 1 Apr 2012 21:28:42 +0300
\r
27 Message-Id: <1333304922-30681-1-git-send-email-tomi.ollila@iki.fi>
\r
28 X-Mailer: git-send-email 1.7.6.1
\r
29 In-Reply-To: <1333195960-31359-1-git-send-email-david@tethera.net>
\r
30 References: <1333195960-31359-1-git-send-email-david@tethera.net>
\r
31 Cc: Tomi Ollila <tomi.ollila@iki.fi>
\r
32 X-BeenThere: notmuch@notmuchmail.org
\r
33 X-Mailman-Version: 2.1.13
\r
35 List-Id: "Use and development of the notmuch mail system."
\r
36 <notmuch.notmuchmail.org>
\r
37 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
38 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
39 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
40 List-Post: <mailto:notmuch@notmuchmail.org>
\r
41 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
42 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
43 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
44 X-List-Received-Date: Sun, 01 Apr 2012 18:28:47 -0000
\r
46 If any of the forked process exits with nonzero value, terminate
\r
47 current operation -- nonzero exit value indicates failure and
\r
48 then there is no point continuing.
\r
51 I tested this by using most of the commands (pushed few tags in
\r
52 addtion to pull, log, status & checkout). I haven't encountered
\r
53 any failures yet in real environment but mangling nmbug to fail
\r
54 does make it fail as expected (s/git/false/ or s/exec @_/exit 1/
\r
55 -- exit ! close $fh could not be tested as there is currently
\r
56 no code paths to arrive there).
\r
58 contrib/nmbug | 37 ++++++++++++++++++++++++++++++++-----
\r
59 1 files changed, 32 insertions(+), 5 deletions(-)
\r
61 diff --git a/contrib/nmbug b/contrib/nmbug
\r
62 index bb0739f..f003ef9 100755
\r
65 @@ -60,6 +60,9 @@ sub git_pipe {
\r
67 my $fh = git_pipe (@_);
\r
68 my $str = join ('', <$fh>);
\r
69 + unless (close $fh) {
\r
70 + die "'git @_' exited with nonzero value\n";
\r
75 @@ -84,7 +87,7 @@ sub spawn {
\r
76 foreach my $line (@{$ioref}) {
\r
77 print $fh $line, "\n";
\r
83 open STDIN, '<', '/dev/null' or die "reopening stdin: $!"
\r
84 @@ -106,6 +109,9 @@ sub get_tags {
\r
86 push @tags, $_ if (m/^$prefix/);
\r
88 + unless (close $fh) {
\r
89 + die "'notmuch search --output=tags *' exited with nonzero value\n";
\r
94 @@ -173,6 +179,10 @@ sub update_index {
\r
95 foreach my $pair (@{$status->{added}}) {
\r
96 index_tags_for_msg ($git, $pair->{id}, 'A', $pair->{tag});
\r
98 + unless (close $git) {
\r
99 + die "'git update-index --index-info' exited with nonzero value\n";
\r
105 @@ -211,8 +221,12 @@ sub index_tags {
\r
106 my @tags = grep { s/^$TAGPREFIX//; } split (' ', $rest);
\r
107 index_tags_for_msg ($git,$id, 'A', @tags);
\r
111 + unless (close $git) {
\r
112 + die "'git update-index --index-info' exited with nonzero value\n";
\r
114 + unless (close $fh) {
\r
115 + die "'notmuch dump -- $query' exited with nonzero value\n";
\r
120 @@ -395,6 +409,9 @@ sub compute_status {
\r
122 push @deleted, $pair;
\r
124 + unless (close $fh) {
\r
125 + die "'notmuch search --output=files id:$id' exited with nonzero value\n";
\r
130 @@ -414,7 +431,12 @@ sub diff_index {
\r
131 qw/diff-index --cached/,
\r
132 "--diff-filter=$filter", qw/--name-only HEAD/ );
\r
134 - return unpack_diff_lines ($fh);
\r
135 + my @lines = unpack_diff_lines ($fh);
\r
136 + unless (close $fh) {
\r
137 + die "'git diff-index --cached --diff-filter=$filter --name-only HEAD' ",
\r
138 + "exited with nonzero value\n";
\r
144 @@ -426,7 +448,12 @@ sub diff_refs {
\r
145 my $fh= git_pipe ( 'diff', "--diff-filter=$filter", '--name-only',
\r
148 - return unpack_diff_lines ($fh);
\r
149 + my @lines = unpack_diff_lines ($fh);
\r
150 + unless (close $fh) {
\r
151 + die "'git diff --diff-filter=$filter --name-only $ref1 $ref2' ",
\r
152 + "exited with nonzero value\n";
\r