Jim Meyering <jim <at> meyering.net>
to control <at> debbugs.gnu.org.
Full text available.Received: (at 6308) by debbugs.gnu.org; 13 Nov 2011 11:54:49 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sun Nov 13 06:54:49 2011 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1RPYe8-0003yI-Qd for submit <at> debbugs.gnu.org; Sun, 13 Nov 2011 06:54:48 -0500 Received: from mx.meyering.net ([88.168.87.75]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from <jim <at> meyering.net>) id 1RPYe6-0003y7-RP; Sun, 13 Nov 2011 06:54:47 -0500 Received: from rho.meyering.net (localhost.localdomain [127.0.0.1]) by rho.meyering.net (Acme Bit-Twister) with ESMTP id 9DF526006A; Sun, 13 Nov 2011 12:54:18 +0100 (CET) From: Jim Meyering <jim <at> meyering.net> To: =?iso-8859-1?Q?=C1ngel_Gonz=E1lez?= <keisial <at> gmail.com> Subject: Re: bug#6308: Preserve command exit code in timeout(3) In-Reply-To: <4C025959.3030406 <at> draigBrady.com> (=?iso-8859-1?Q?=22P=E1drai?= =?iso-8859-1?Q?g?= Brady"'s message of "Sun, 30 May 2010 13:26:01 +0100") References: <4C01AE18.9070100 <at> gmail.com> <4C025959.3030406 <at> draigBrady.com> Date: Sun, 13 Nov 2011 12:54:18 +0100 Message-ID: <8762ionsph.fsf <at> rho.meyering.net> Lines: 20 MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.7 (--) X-Debbugs-Envelope-To: 6308 Cc: =?iso-8859-1?Q?P=E1draig?= Brady <P <at> draigBrady.com>, 6308 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Sender: debbugs-submit-bounces <at> debbugs.gnu.org Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org X-Spam-Score: -2.7 (--) tags 6308 moreinfo thanks P=E1draig Brady wrote: > On 30/05/10 01:15, =C1ngel Gonz=E1lez wrote: >> I wanted to keep the original exit status of the command run by >> timeout(3), even after sending a timeout signal. >> Thus I added a --exit-status parameter to it. Here it is in case you >> find that useful, too. > > Thanks very much for the patch. > At first thought it seems like a very unusual use case. > Can you describe your use in a bit more detail to > help us determine if this is generally useful. Thanks again for the patch. However, without justification, well... it won't go far. Can you describe how the new behavior is useful to you? It's been 18 months, now...
bug-coreutils <at> gnu.org:bug#6308; Package coreutils.
Full text available.Received: (at 6308) by debbugs.gnu.org; 30 May 2010 12:29:24 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sun May 30 08:29:24 2010 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1OIhds-0000DB-Fz for submit <at> debbugs.gnu.org; Sun, 30 May 2010 08:29:24 -0400 Received: from mail1.slb.deg.dub.stisp.net ([84.203.253.98]) by debbugs.gnu.org with smtp (Exim 4.69) (envelope-from <P <at> draigBrady.com>) id 1OIhdr-0000D2-01 for 6308 <at> debbugs.gnu.org; Sun, 30 May 2010 08:29:23 -0400 Received: (qmail 90287 invoked from network); 30 May 2010 12:29:16 -0000 Received: from unknown (HELO ?192.168.2.25?) (84.203.137.218) by mail1.slb.deg.dub.stisp.net with SMTP; 30 May 2010 12:29:16 -0000 Message-ID: <4C025959.3030406 <at> draigBrady.com> Date: Sun, 30 May 2010 13:26:01 +0100 From: =?ISO-8859-1?Q?P=E1draig_Brady?= <P <at> draigBrady.com> User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100227 Thunderbird/3.0.3 MIME-Version: 1.0 To: =?ISO-8859-1?Q?=C1ngel_Gonz=E1lez?= <keisial <at> gmail.com> Subject: Re: bug#6308: Preserve command exit code in timeout(3) References: <4C01AE18.9070100 <at> gmail.com> In-Reply-To: <4C01AE18.9070100 <at> gmail.com> X-Enigmail-Version: 1.0.1 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.8 (--) X-Debbugs-Envelope-To: 6308 Cc: 6308 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Sender: debbugs-submit-bounces <at> debbugs.gnu.org Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org X-Spam-Score: -2.8 (--) On 30/05/10 01:15, ngel Gonzlez wrote: > I wanted to keep the original exit status of the command run by > timeout(3), even after sending a timeout signal. > Thus I added a --exit-status parameter to it. Here it is in case you > find that useful, too. Thanks very much for the patch. At first thought it seems like a very unusual use case. Can you describe your use in a bit more detail to help us determine if this is generally useful. cheers, Pdraig.
owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org:bug#6308; Package coreutils.
Full text available.
Received: (at submit) by debbugs.gnu.org; 30 May 2010 00:22:46 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat May 29 20:22:46 2010
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
by debbugs.gnu.org with esmtp (Exim 4.69)
(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
id 1OIWIf-00064V-UQ
for submit <at> debbugs.gnu.org; Sat, 29 May 2010 20:22:46 -0400
Received: from mail.gnu.org ([199.232.76.166] helo=mx10.gnu.org)
by debbugs.gnu.org with esmtp (Exim 4.69)
(envelope-from <keisial <at> gmail.com>) id 1OIWBs-000619-Cz
for submit <at> debbugs.gnu.org; Sat, 29 May 2010 20:15:45 -0400
Received: from lists.gnu.org ([199.232.76.165]:56951)
by monty-python.gnu.org with esmtps
(TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60)
(envelope-from <keisial <at> gmail.com>) id 1OIWBn-0002cz-PR
for submit <at> debbugs.gnu.org; Sat, 29 May 2010 20:15:39 -0400
Received: from [140.186.70.92] (port=40843 helo=eggs.gnu.org)
by lists.gnu.org with esmtp (Exim 4.43) id 1OIWBl-0000SP-JJ
for bug-coreutils <at> gnu.org; Sat, 29 May 2010 20:15:39 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org
X-Spam-Level:
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM,
T_DKIM_INVALID,
T_STOX_BOUND_090909_B autolearn=unavailable version=3.3.1
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69)
(envelope-from <keisial <at> gmail.com>) id 1OIWBk-00066L-Fk
for bug-coreutils <at> gnu.org; Sat, 29 May 2010 20:15:37 -0400
Received: from mail-ww0-f41.google.com ([74.125.82.41]:60461)
by eggs.gnu.org with esmtp (Exim 4.69)
(envelope-from <keisial <at> gmail.com>) id 1OIWBk-000668-Bb
for bug-coreutils <at> gnu.org; Sat, 29 May 2010 20:15:36 -0400
Received: by wwi17 with SMTP id 17so1651605wwi.0
for <bug-coreutils <at> gnu.org>; Sat, 29 May 2010 17:15:35 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
h=domainkey-signature:received:received:message-id:date:from
:user-agent:mime-version:to:subject:content-type;
bh=Ozi/CA6KTYAnLgj0KkzgNPBE4XEdEoW7KTv4wyAhExA=;
b=WlsCndD8vJwoFrvd2Mtse3r1De17yoVAn4WT/MzKpWDGF/d3LLF9fYwFF1CprNCrOH
PiQ0JCfSZYOS7bKAaKAy0nlxJh6fez1OKZS/+3PXJMgaF6ZLMqQNmasLKPYTA2XiUzQO
O2ooU4OsAljLynuvZQ4NiLGO2v3lgJjTl2FQg=
DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;
h=message-id:date:from:user-agent:mime-version:to:subject
:content-type;
b=sSsd4j1g9TvfzJDRZFxI6VuYVEGqDp1S2nkPtFsJ/4ZqdyQoUTdmhT5kYxz3yVc5U7
zMlMqILj2ZqwfyGWrqI9MlUwL55nmdpXyfIBqckO3xZC4zbUdL5p6FFk5np47wXcPD0b
1lk+qVvAqyUWkR4nm5aC1yyt23HM1A6QdR7bk=
Received: by 10.227.136.71 with SMTP id q7mr2240129wbt.67.1275178535395;
Sat, 29 May 2010 17:15:35 -0700 (PDT)
Received: from [192.168.1.26] ([83.51.57.103])
by mx.google.com with ESMTPS id y31sm28423073wby.16.2010.05.29.17.15.34
(version=SSLv3 cipher=RC4-MD5); Sat, 29 May 2010 17:15:34 -0700 (PDT)
Message-ID: <4C01AE18.9070100 <at> gmail.com>
Date: Sun, 30 May 2010 02:15:20 +0200
From: "=?ISO-8859-1?Q?=C1ngel_Gonz=E1lez?=" <keisial <at> gmail.com>
User-Agent: Thunderbird
MIME-Version: 1.0
To: bug-coreutils <bug-coreutils <at> gnu.org>
Subject: Preserve command exit code in timeout(3)
Content-Type: multipart/mixed; boundary="------------030602010008020606020808"
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6,
seldom 2.4 (older, 4)
X-Spam-Score: -5.9 (-----)
X-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Sat, 29 May 2010 20:22:44 -0400
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -5.9 (-----)
This is a multi-part message in MIME format.
--------------030602010008020606020808
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
I wanted to keep the original exit status of the command run by
timeout(3), even after sending a timeout signal.
Thus I added a --exit-status parameter to it. Here it is in case you
find that useful, too.
--------------030602010008020606020808
Content-Type: text/x-patch;
name="timeout-exit-status.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="timeout-exit-status.patch"
diff --git a/src/timeout.c b/src/timeout.c
index e2234c3..29f5bec 100644
--- a/src/timeout.c
+++ b/src/timeout.c
@@ -64,6 +64,7 @@
#define AUTHORS proper_name_utf8 ("Padraig Brady", "P\303\241draig Brady")
static int timed_out;
+static int command_exit_status = 0;
static int term_signal = SIGTERM; /* same default as kill command. */
static int monitored_pid;
static int sigs_to_ignore[NSIG]; /* so monitor can ignore sigs it resends. */
@@ -73,6 +74,7 @@ static struct option const long_options[] =
{
{"kill-after", required_argument, NULL, 'k'},
{"signal", required_argument, NULL, 's'},
+ {"exit-status", no_argument, NULL, 'x'},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
{NULL, 0, NULL, 0}
@@ -141,7 +143,10 @@ Mandatory arguments to long options are mandatory for short options too.\n\
-s, --signal=SIGNAL\n\
specify the signal to be sent on timeout.\n\
SIGNAL may be a name like `HUP' or a number.\n\
- See `kill -l` for a list of signals\n"), stdout);
+ See `kill -l` for a list of signals\n\
+ -x, --exit-status\n\
+ exit with the same status as COMMAND even if the \n\
+ command timed out\n"), stdout);
fputs (HELP_OPTION_DESCRIPTION, stdout);
fputs (VERSION_OPTION_DESCRIPTION, stdout);
@@ -152,11 +157,12 @@ DURATION is an integer with an optional suffix:\n\
"), stdout);
fputs (_("\n\
-If the command times out, then exit with status 124. Otherwise, exit\n\
-with the status of COMMAND. If no signal is specified, send the TERM\n\
-signal upon timeout. The TERM signal kills any process that does not\n\
-block or catch that signal. For other processes, it may be necessary to\n\
-use the KILL (9) signal, since this signal cannot be caught.\n"), stdout);
+If the command times out, and --exit-status was not set, then exit with \n\
+status 124. Otherwise, exit with the status of COMMAND. If no signal \n\
+is specified, send the TERM signal upon timeout. The TERM signal kills \n\
+any process that does not block or catch that signal. For other processes, \n\
+it may be necessary to use the KILL (9) signal, since this signal cannot \n\
+be caught.\n"), stdout);
emit_ancillary_info ();
}
exit (status);
@@ -253,7 +259,7 @@ main (int argc, char **argv)
initialize_exit_failure (EXIT_CANCELED);
atexit (close_stdout);
- while ((c = getopt_long (argc, argv, "+k:s:", long_options, NULL)) != -1)
+ while ((c = getopt_long (argc, argv, "+k:s:x", long_options, NULL)) != -1)
{
switch (c)
{
@@ -266,6 +272,9 @@ main (int argc, char **argv)
if (term_signal == -1)
usage (EXIT_CANCELED);
break;
+ case 'x':
+ command_exit_status = 1;
+ break;
case_GETOPT_HELP_CHAR;
@@ -351,7 +360,7 @@ main (int argc, char **argv)
}
}
- if (timed_out)
+ if (timed_out && !command_exit_status)
return EXIT_TIMEDOUT;
else
return status;
--------------030602010008020606020808--
"Ángel González" <keisial <at> gmail.com>:bug-coreutils <at> gnu.org.
Full text available.owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org:bug#6308; Package coreutils.
Full text available.
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.