From debbugs-submit-bounces@debbugs.gnu.org Sat May 29 20:22:46 2010 Received: (at submit) by debbugs.gnu.org; 30 May 2010 00:22:46 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OIWIf-00064V-UQ for submit@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 ) id 1OIWBs-000619-Cz for submit@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 ) id 1OIWBn-0002cz-PR for submit@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@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 ) id 1OIWBk-00066L-Fk for bug-coreutils@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 ) id 1OIWBk-000668-Bb for bug-coreutils@gnu.org; Sat, 29 May 2010 20:15:36 -0400 Received: by wwi17 with SMTP id 17so1651605wwi.0 for ; 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@gmail.com> Date: Sun, 30 May 2010 02:15:20 +0200 From: "=?ISO-8859-1?Q?=C1ngel_Gonz=E1lez?=" User-Agent: Thunderbird MIME-Version: 1.0 To: bug-coreutils 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@debbugs.gnu.org X-Mailman-Version: 2.1.11 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: -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-- From debbugs-submit-bounces@debbugs.gnu.org Sun May 30 08:29:24 2010 Received: (at 6308) by debbugs.gnu.org; 30 May 2010 12:29:24 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OIhds-0000DB-Fz for submit@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 ) id 1OIhdr-0000D2-01 for 6308@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@draigBrady.com> Date: Sun, 30 May 2010 13:26:01 +0100 From: =?ISO-8859-1?Q?P=E1draig_Brady?= 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?= Subject: Re: bug#6308: Preserve command exit code in timeout(3) References: <4C01AE18.9070100@gmail.com> In-Reply-To: <4C01AE18.9070100@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@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 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.8 (--) On 30/05/10 01:15, Ángel González 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, Pádraig. From debbugs-submit-bounces@debbugs.gnu.org Sun Nov 13 06:54:49 2011 Received: (at 6308) by debbugs.gnu.org; 13 Nov 2011 11:54:49 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RPYe8-0003yI-Qd for submit@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 ) 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 To: =?iso-8859-1?Q?=C1ngel_Gonz=E1lez?= Subject: Re: bug#6308: Preserve command exit code in timeout(3) In-Reply-To: <4C025959.3030406@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@gmail.com> <4C025959.3030406@draigBrady.com> Date: Sun, 13 Nov 2011 12:54:18 +0100 Message-ID: <8762ionsph.fsf@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 , 6308@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 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.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... From debbugs-submit-bounces@debbugs.gnu.org Sun Oct 21 21:56:47 2012 Received: (at 6308) by debbugs.gnu.org; 22 Oct 2012 01:56:47 +0000 Received: from localhost ([127.0.0.1]:54745 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TQ7G1-0003OS-Q8 for submit@debbugs.gnu.org; Sun, 21 Oct 2012 21:56:47 -0400 Received: from wagner.kr.tuwien.ac.at ([128.130.205.32]:41068) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TQ2I4-0004jz-I2 for 6308@debbugs.gnu.org; Sun, 21 Oct 2012 16:38:33 -0400 Received: from mahler.kr.tuwien.ac.at (mahler.kr.tuwien.ac.at [128.130.205.9]) by wagner.kr.tuwien.ac.at (8.14.3/8.13.8/SuSE Linux 0.8) with ESMTP id q9LKahZM002607; Sun, 21 Oct 2012 22:36:45 +0200 Received: from mahler.kr.tuwien.ac.at (localhost [127.0.0.1]) by mahler.kr.tuwien.ac.at (8.14.4/8.14.4/SuSE Linux 0.8) with ESMTP id q9LKahmC003868; Sun, 21 Oct 2012 22:36:43 +0200 Received: (from tkren@localhost) by mahler.kr.tuwien.ac.at (8.14.4/8.14.4/Submit) id q9LKahx0003859; Sun, 21 Oct 2012 22:36:43 +0200 X-Authentication-Warning: mahler.kr.tuwien.ac.at: tkren set sender to tkren@kr.tuwien.ac.at using -f Date: Sun, 21 Oct 2012 22:36:43 +0200 From: Thomas Krennwallner To: Jim Meyering Subject: Re: bug#6308: Preserve command exit code in timeout(3) Message-ID: <20121021203643.GA3624@kr.tuwien.ac.at> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <8762ionsph.fsf@rho.meyering.net> Organization: Vienna University of Technology X-Accept-Language: en,de User-Agent: Mutt/1.5.21 (2010-09-15) Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by wagner.kr.tuwien.ac.at id q9LKahZM002607 X-Spam-Score: 1.6 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has identified this incoming email as possible spam. The original message has been attached to this so you can view it (if it isn't spam) or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Dear Jim, dear Pádraig, preserving the command's exit code is useful for, e.g., running solver competitions, where competition participants have an upper bound on the runtime for finding solutions to very hard problems. [...] Content analysis details: (1.6 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% [score: 0.5000] 1.5 FAKE_REPLY_C FAKE_REPLY_C X-Debbugs-Envelope-To: 6308 X-Mailman-Approved-At: Sun, 21 Oct 2012 21:56:44 -0400 Cc: =?iso-8859-1?Q?P=E1draig?= Brady , =?iso-8859-1?Q?=C1ngel_Gonz=E1lez?= , 6308@debbugs.gnu.org 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.6 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has identified this incoming email as possible spam. The original message has been attached to this so you can view it (if it isn't spam) or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Dear Jim, dear Pádraig, preserving the command's exit code is useful for, e.g., running solver competitions, where competition participants have an upper bound on the runtime for finding solutions to very hard problems. [...] Content analysis details: (1.6 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% [score: 0.5000] 1.5 FAKE_REPLY_C FAKE_REPLY_C Dear Jim, dear P=E1draig, preserving the command's exit code is useful for, e.g., running solver competitions, where competition participants have an upper bound on the runtime for finding solutions to very hard problems. Imagine you want to run a command which is outputting (periodically or on-request) solutions to optimization problems, where better and better solutions will be printed over time, until the final solution is obtained. Now if the process gets interrupted by timeout's signal, the command will return with an exit code different from the one that means "final solution found". If there was already an "interesting" solution found, a particular exit code would be returned, and if no solution has been found until the signal was received would result in yet another exit code. This way, one would easily obtain the status of the solution without parsing the output. For exit code 124 one would only know that there was a timeout, but not if the computation has already revealed "interesting" results. I'm thus very interested into seeing timeout --exit-status. Best, TK --=20 Thomas Krennwallner University assistant =2E TU Wien - Vienna University of Technology Institute of Information Systems Favoritenstrasse 9-11, 1040 Wien, Austria =2E T: +43 1 58801 18469 F: +43 1 58801 918469 tkren AT kr DOT tuwien DOT ac DOT at http://www.kr.tuwien.ac.at/staff/tkren/ =2E DVR: 0005886 From debbugs-submit-bounces@debbugs.gnu.org Mon Oct 22 05:22:13 2012 Received: (at 6308) by debbugs.gnu.org; 22 Oct 2012 09:22:13 +0000 Received: from localhost ([127.0.0.1]:55009 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TQED6-0007BR-C1 for submit@debbugs.gnu.org; Mon, 22 Oct 2012 05:22:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:14278) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TQED3-0007BB-Ub for 6308@debbugs.gnu.org; Mon, 22 Oct 2012 05:22:11 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q9M9KJ1G026581 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 22 Oct 2012 05:20:19 -0400 Received: from [10.36.116.57] (ovpn-116-57.ams2.redhat.com [10.36.116.57]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q9M9KFIm008470 (version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Mon, 22 Oct 2012 05:20:18 -0400 Message-ID: <50850FCE.80106@draigBrady.com> Date: Mon, 22 Oct 2012 10:20:14 +0100 From: =?ISO-8859-1?Q?P=E1draig_Brady?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120615 Thunderbird/13.0.1 MIME-Version: 1.0 To: Thomas Krennwallner Subject: Re: bug#6308: Preserve command exit code in timeout(3) References: <20121021203643.GA3624@kr.tuwien.ac.at> In-Reply-To: <20121021203643.GA3624@kr.tuwien.ac.at> Content-Type: text/plain; charset=ISO-8859-1; format=flowed X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by mx1.redhat.com id q9M9KJ1G026581 X-Spam-Score: -4.2 (----) X-Debbugs-Envelope-To: 6308 Cc: =?ISO-8859-1?Q?=C1ngel_Gonz=E1lez?= , Jim Meyering , 6308@debbugs.gnu.org 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: -4.2 (----) On 10/21/2012 09:36 PM, Thomas Krennwallner wrote: > Dear Jim, dear P=E1draig, > > preserving the command's exit code is useful for, e.g., running solver > competitions, where competition participants have an upper bound on the > runtime for finding solutions to very hard problems. > > Imagine you want to run a command which is outputting (periodically or > on-request) solutions to optimization problems, where better and better > solutions will be printed over time, until the final solution is > obtained. > > Now if the process gets interrupted by timeout's signal, the command > will return with an exit code different from the one that means "final > solution found". If there was already an "interesting" solution found, > a particular exit code would be returned, and if no solution has been > found until the signal was received would result in yet another exit > code. > > This way, one would easily obtain the status of the solution without > parsing the output. For exit code 124 one would only know that there > was a timeout, but not if the computation has already revealed > "interesting" results. > > I'm thus very interested into seeing timeout --exit-status. Ok cool. It's tempting to support this without an option. I.E. for all commands that exit without WIFSIGNALED being set, i.e. for all commands that catch and exit on signal reception. However that wouldn't work in general I think due to cascading timeout commands or commands that catch signals for cleanup etc., though I suppose the latter case might be catered for by specifying a specific signal with the -s option. So I'll look at adding this new option right after the imminent 8.20 release. thanks, P=E1draig. From debbugs-submit-bounces@debbugs.gnu.org Mon Oct 22 08:29:23 2012 Received: (at 6308) by debbugs.gnu.org; 22 Oct 2012 12:29:23 +0000 Received: from localhost ([127.0.0.1]:55335 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TQH8E-00064j-4F for submit@debbugs.gnu.org; Mon, 22 Oct 2012 08:29:23 -0400 Received: from wagner.kr.tuwien.ac.at ([128.130.205.32]:53331) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TQH8B-00064V-Ii for 6308@debbugs.gnu.org; Mon, 22 Oct 2012 08:29:21 -0400 Received: from mahler.kr.tuwien.ac.at (mahler.kr.tuwien.ac.at [128.130.205.9]) by wagner.kr.tuwien.ac.at (8.14.3/8.13.8/SuSE Linux 0.8) with ESMTP id q9MCRQhW013569; Mon, 22 Oct 2012 14:27:28 +0200 Received: from mahler.kr.tuwien.ac.at (localhost [127.0.0.1]) by mahler.kr.tuwien.ac.at (8.14.4/8.14.4/SuSE Linux 0.8) with ESMTP id q9MCRQtt010140; Mon, 22 Oct 2012 14:27:26 +0200 Received: (from tkren@localhost) by mahler.kr.tuwien.ac.at (8.14.4/8.14.4/Submit) id q9MCRQJ7010131; Mon, 22 Oct 2012 14:27:26 +0200 X-Authentication-Warning: mahler.kr.tuwien.ac.at: tkren set sender to tkren@kr.tuwien.ac.at using -f Date: Mon, 22 Oct 2012 14:27:26 +0200 From: Thomas Krennwallner To: =?iso-8859-1?Q?P=E1draig?= Brady Subject: Re: bug#6308: Preserve command exit code in timeout(3) Message-ID: <20121022122726.GA5407@kr.tuwien.ac.at> References: <20121021203643.GA3624@kr.tuwien.ac.at> <50850FCE.80106@draigBrady.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <50850FCE.80106@draigBrady.com> Organization: Vienna University of Technology X-Accept-Language: en,de User-Agent: Mutt/1.5.21 (2010-09-15) Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by wagner.kr.tuwien.ac.at id q9MCRQhW013569 X-Spam-Score: 0.1 (/) X-Debbugs-Envelope-To: 6308 Cc: =?iso-8859-1?Q?=C1ngel_Gonz=E1lez?= , Jim Meyering , 6308@debbugs.gnu.org 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: 0.1 (/) On Mon Oct 22, 2012 10:20:14AM +0100, P=E1draig Brady wrote: > On 10/21/2012 09:36 PM, Thomas Krennwallner wrote: [...] > >I'm thus very interested into seeing timeout --exit-status. >=20 > Ok cool. >=20 > It's tempting to support this without an option. > I.E. for all commands that exit without WIFSIGNALED being set, > i.e. for all commands that catch and exit on signal reception. > However that wouldn't work in general I think due to cascading > timeout commands or commands that catch signals for cleanup etc., > though I suppose the latter case might be catered for by > specifying a specific signal with the -s option. Yes, I completely agree. And would only make a difference for programs that carry on meaning with their exit code, i.e., where the code depends on the computation, as described in my use case. The default use is IMHO just error exit in programs, and most have it implemented this way (think of clean-up at signal reception). Having a default exit code of 124 is good for those standard programs. > So I'll look at adding this new option right after the > imminent 8.20 release. Thank you, this sounds like good news! Best, TK --=20 Thomas Krennwallner University assistant =2E TU Wien - Vienna University of Technology Institute of Information Systems Favoritenstrasse 9-11, 1040 Wien, Austria =2E T: +43 1 58801 18469 F: +43 1 58801 918469 tkren AT kr DOT tuwien DOT ac DOT at http://www.kr.tuwien.ac.at/staff/tkren/ =2E DVR: 0005886 From debbugs-submit-bounces@debbugs.gnu.org Sun Oct 28 20:46:00 2012 Received: (at 6308) by debbugs.gnu.org; 29 Oct 2012 00:46:00 +0000 Received: from localhost ([127.0.0.1]:37083 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TSdUN-00061Y-Ad for submit@debbugs.gnu.org; Sun, 28 Oct 2012 20:45:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35901) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TSdUK-00061P-HC for 6308@debbugs.gnu.org; Sun, 28 Oct 2012 20:45:58 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q9T0hVTf001701 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 28 Oct 2012 20:43:31 -0400 Received: from [10.36.116.16] (ovpn-116-16.ams2.redhat.com [10.36.116.16]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q9T0hRLJ008260 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 28 Oct 2012 20:43:29 -0400 Message-ID: <508DD12F.2050607@draigBrady.com> Date: Mon, 29 Oct 2012 00:43:27 +0000 From: =?ISO-8859-1?Q?P=E1draig_Brady?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120615 Thunderbird/13.0.1 MIME-Version: 1.0 To: Thomas Krennwallner Subject: Re: bug#6308: Preserve command exit code in timeout(3) References: <20121021203643.GA3624@kr.tuwien.ac.at> <50850FCE.80106@draigBrady.com> <20121022122726.GA5407@kr.tuwien.ac.at> In-Reply-To: <20121022122726.GA5407@kr.tuwien.ac.at> Content-Type: multipart/mixed; boundary="------------080104040503020809020807" X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-Spam-Score: -4.2 (----) X-Debbugs-Envelope-To: 6308 Cc: =?ISO-8859-1?Q?=C1ngel_Gonz=E1lez?= , Jim Meyering , 6308@debbugs.gnu.org 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.9 (------) This is a multi-part message in MIME format. --------------080104040503020809020807 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by mx1.redhat.com id q9T0hVTf001701 On 10/22/2012 01:27 PM, Thomas Krennwallner wrote: > On Mon Oct 22, 2012 10:20:14AM +0100, P=E1draig Brady wrote: >> On 10/21/2012 09:36 PM, Thomas Krennwallner wrote: > [...] >>> I'm thus very interested into seeing timeout --exit-status. >> >> Ok cool. >> >> It's tempting to support this without an option. >> I.E. for all commands that exit without WIFSIGNALED being set, >> i.e. for all commands that catch and exit on signal reception. >> However that wouldn't work in general I think due to cascading >> timeout commands or commands that catch signals for cleanup etc., >> though I suppose the latter case might be catered for by >> specifying a specific signal with the -s option. > > Yes, I completely agree. And would only make a difference for programs > that carry on meaning with their exit code, i.e., where the code depend= s > on the computation, as described in my use case. The default use is > IMHO just error exit in programs, and most have it implemented this way > (think of clean-up at signal reception). Having a default exit code of > 124 is good for those standard programs. > >> So I'll look at adding this new option right after the >> imminent 8.20 release. > > Thank you, this sounds like good news! Proposed patch is attached. thanks, P=E1draig. --------------080104040503020809020807 Content-Type: text/x-patch; name="timeout-exit-status.diff" Content-Disposition: attachment; filename="timeout-exit-status.diff" Content-Transfer-Encoding: 7bit >From 0c5f991abe9875741d1812f5be91c249d9418b17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81ngel=20Gonz=C3=A1lez?= Date: Mon, 29 Oct 2012 00:36:08 +0000 Subject: [PATCH] timeout: add --exit-status to always propagate the command's exit status It's useful for commands that support running for an indeterminite amount of time, to not return a specific timeout exit status (124), and instead let the command handle the timeout signal and return a status for the work done so far. * doc/coreutils.texi (timeout invocation): Describe the new option. * src/timeout.c (use_exit_status): A new global boolean to enable the --exit-status behavior. (usage): Describe the new option. (main): Don't return EXIT_TIMEOUT of use_exit_status is set. * tests/misc/timeout.sh: Add a test for the new option. --- doc/coreutils.texi | 6 ++++++ src/timeout.c | 28 +++++++++++++++++++--------- tests/misc/timeout.sh | 5 +++++ 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/doc/coreutils.texi b/doc/coreutils.texi index e2b1059..6e047c5 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi @@ -15890,6 +15890,12 @@ The program accepts the following options. Also see @ref{Common options}. Options must precede operands. @table @samp +@item --exit-status +@opindex --exit-status +Return the exit status of the managed @var{command} on timeout, rather than +a specific exit status indicating a timeout. This is useful if the +managed @var{command} supports running for an indeterminite amount of time. + @item --foreground @opindex --foreground Don't create a separate background program group, so that diff --git a/src/timeout.c b/src/timeout.c index 4ce18ad..3f90ac7 100644 --- a/src/timeout.c +++ b/src/timeout.c @@ -81,12 +81,14 @@ static int timed_out; static int term_signal = SIGTERM; /* same default as kill command. */ static int monitored_pid; static double kill_after; -static bool foreground; /* whether to use another program group. */ +static bool foreground; /* whether to use another program group. */ +static bool use_exit_status; /* whether to use a timeout status or not. */ /* for long options with no corresponding short option, use enum */ enum { - FOREGROUND_OPTION = CHAR_MAX + 1 + FOREGROUND_OPTION = CHAR_MAX + 1, + EXIT_STATUS_OPTION }; static struct option const long_options[] = @@ -94,6 +96,7 @@ static struct option const long_options[] = {"kill-after", required_argument, NULL, 'k'}, {"signal", required_argument, NULL, 's'}, {"foreground", no_argument, NULL, FOREGROUND_OPTION}, + {"exit-status", no_argument, NULL, EXIT_STATUS_OPTION}, {GETOPT_HELP_OPTION_DECL}, {GETOPT_VERSION_OPTION_DECL}, {NULL, 0, NULL, 0} @@ -214,6 +217,9 @@ Start COMMAND, and kill it if still running after DURATION.\n\ Mandatory arguments to long options are mandatory for short options too.\n\ "), stdout); fputs (_("\ + --exit-status\n\ + exit with the same status as COMMAND even if the\n\ + command timed out\n\ --foreground\n\ When not running timeout directly from a shell prompt,\n\ allow COMMAND to read from the TTY and receive TTY signals.\n\ @@ -235,12 +241,12 @@ DURATION is a floating point number with an optional suffix:\n\ or 'd' for days.\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. If the\n\ -KILL (9) signal is sent, the exit status is 128+9 rather than 124.\n"), stdout); +If the command times out, and --exit-status is 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. It may be necessary\n\ +to use the KILL (9) signal, since this signal cannot be caught, in which\n\ +case the exit status is 128+9 rather than 124.\n"), stdout); emit_ancillary_info (); } exit (status); @@ -376,6 +382,10 @@ main (int argc, char **argv) foreground = true; break; + case EXIT_STATUS_OPTION: + use_exit_status = true; + break; + case_GETOPT_HELP_CHAR; case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); @@ -470,7 +480,7 @@ main (int argc, char **argv) } } - if (timed_out) + if (timed_out && !use_exit_status) return EXIT_TIMEDOUT; else return status; diff --git a/tests/misc/timeout.sh b/tests/misc/timeout.sh index 57a4e15..3fa8522 100755 --- a/tests/misc/timeout.sh +++ b/tests/misc/timeout.sh @@ -36,6 +36,11 @@ test $? = 2 || fail=1 timeout 1 sleep 10 test $? = 124 || fail=1 +# exit status propagation even on timeout +timeout --exit-status 1 sleep 10 +# exit status should be 128+TERM +test $? = 124 && fail=1 + # kill delay. Note once the initial timeout triggers, # the exit status will be 124 even if the command # exits on its own accord. -- 1.7.6.4 --------------080104040503020809020807-- From debbugs-submit-bounces@debbugs.gnu.org Mon Oct 29 04:37:25 2012 Received: (at 6308) by debbugs.gnu.org; 29 Oct 2012 08:37:25 +0000 Received: from localhost ([127.0.0.1]:37350 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TSkqa-0008RT-W6 for submit@debbugs.gnu.org; Mon, 29 Oct 2012 04:37:25 -0400 Received: from wagner.kr.tuwien.ac.at ([128.130.205.32]:56046) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TSkqX-0008RJ-6u for 6308@debbugs.gnu.org; Mon, 29 Oct 2012 04:37:23 -0400 Received: from mahler.kr.tuwien.ac.at (mahler.kr.tuwien.ac.at [128.130.205.9]) by wagner.kr.tuwien.ac.at (8.14.3/8.13.8/SuSE Linux 0.8) with ESMTP id q9T8YoTB022887; Mon, 29 Oct 2012 09:34:52 +0100 Received: from mahler.kr.tuwien.ac.at (localhost [127.0.0.1]) by mahler.kr.tuwien.ac.at (8.14.4/8.14.4/SuSE Linux 0.8) with ESMTP id q9T8YnC3030442; Mon, 29 Oct 2012 09:34:49 +0100 Received: (from tkren@localhost) by mahler.kr.tuwien.ac.at (8.14.4/8.14.4/Submit) id q9T8YnCW030434; Mon, 29 Oct 2012 09:34:49 +0100 X-Authentication-Warning: mahler.kr.tuwien.ac.at: tkren set sender to tkren@kr.tuwien.ac.at using -f Date: Mon, 29 Oct 2012 09:34:49 +0100 From: Thomas Krennwallner To: =?iso-8859-1?Q?P=E1draig?= Brady Subject: Re: bug#6308: Preserve command exit code in timeout(3) Message-ID: <20121029083449.GA30420@kr.tuwien.ac.at> References: <20121021203643.GA3624@kr.tuwien.ac.at> <50850FCE.80106@draigBrady.com> <20121022122726.GA5407@kr.tuwien.ac.at> <508DD12F.2050607@draigBrady.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <508DD12F.2050607@draigBrady.com> Organization: Vienna University of Technology X-Accept-Language: en,de User-Agent: Mutt/1.5.21 (2010-09-15) Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by wagner.kr.tuwien.ac.at id q9T8YoTB022887 X-Spam-Score: 0.2 (/) X-Debbugs-Envelope-To: 6308 Cc: =?iso-8859-1?Q?=C1ngel_Gonz=E1lez?= , Jim Meyering , 6308@debbugs.gnu.org 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: 0.2 (/) On Mon Oct 29, 2012 12:43:27AM +0000, P=E1draig Brady wrote: > On 10/22/2012 01:27 PM, Thomas Krennwallner wrote: > >On Mon Oct 22, 2012 10:20:14AM +0100, P=E1draig Brady wrote: > >>On 10/21/2012 09:36 PM, Thomas Krennwallner wrote: > >[...] > >>>I'm thus very interested into seeing timeout --exit-status. > >> > >>Ok cool. > >> > >>It's tempting to support this without an option. > >>I.E. for all commands that exit without WIFSIGNALED being set, > >>i.e. for all commands that catch and exit on signal reception. > >>However that wouldn't work in general I think due to cascading > >>timeout commands or commands that catch signals for cleanup etc., > >>though I suppose the latter case might be catered for by > >>specifying a specific signal with the -s option. > > > >Yes, I completely agree. And would only make a difference for program= s > >that carry on meaning with their exit code, i.e., where the code depen= ds > >on the computation, as described in my use case. The default use is > >IMHO just error exit in programs, and most have it implemented this wa= y > >(think of clean-up at signal reception). Having a default exit code o= f > >124 is good for those standard programs. > > > >>So I'll look at adding this new option right after the > >>imminent 8.20 release. > > > >Thank you, this sounds like good news! >=20 > Proposed patch is attached. I've tried it and it works flawlessly. Thank you! Best, TK --=20 Thomas Krennwallner University assistant =2E TU Wien - Vienna University of Technology Institute of Information Systems Favoritenstrasse 9-11, 1040 Wien, Austria =2E T: +43 1 58801 18469 F: +43 1 58801 918469 tkren AT kr DOT tuwien DOT ac DOT at http://www.kr.tuwien.ac.at/staff/tkren/ =2E DVR: 0005886 From debbugs-submit-bounces@debbugs.gnu.org Mon Oct 29 04:46:59 2012 Received: (at 6308) by debbugs.gnu.org; 29 Oct 2012 08:47:00 +0000 Received: from localhost ([127.0.0.1]:37368 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TSkzr-0000Ft-KU for submit@debbugs.gnu.org; Mon, 29 Oct 2012 04:46:59 -0400 Received: from mx.meyering.net ([88.168.87.75]:37157) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TSkzo-0000Fj-NZ for 6308@debbugs.gnu.org; Mon, 29 Oct 2012 04:46:57 -0400 Received: from rho.meyering.net (rho [127.0.0.1]) by rho.meyering.net (Acme Bit-Twister) with ESMTP id BCBC2600E3; Mon, 29 Oct 2012 09:44:30 +0100 (CET) From: Jim Meyering To: =?iso-8859-1?Q?P=E1draig?= Brady Subject: Re: bug#6308: Preserve command exit code in timeout(3) In-Reply-To: <508DD12F.2050607@draigBrady.com> (=?iso-8859-1?Q?=22P=E1drai?= =?iso-8859-1?Q?g?= Brady"'s message of "Mon, 29 Oct 2012 00:43:27 +0000") References: <20121021203643.GA3624@kr.tuwien.ac.at> <50850FCE.80106@draigBrady.com> <20121022122726.GA5407@kr.tuwien.ac.at> <508DD12F.2050607@draigBrady.com> Date: Mon, 29 Oct 2012 09:44:30 +0100 Message-ID: <87sj8xhdld.fsf@rho.meyering.net> Lines: 45 MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.2 (/) X-Debbugs-Envelope-To: 6308 Cc: 6308@debbugs.gnu.org, =?iso-8859-1?Q?=C1ngel?= =?iso-8859-1?Q?_Gonz=E1lez?= , Thomas Krennwallner 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: 0.2 (/) P=E1draig Brady wrote: ... > Subject: [PATCH] timeout: add --exit-status to always propagate the comma= nd's > exit status > > It's useful for commands that support running for an indeterminite > amount of time, to not return a specific timeout exit status (124), > and instead let the command handle the timeout signal and return > a status for the work done so far. > > * doc/coreutils.texi (timeout invocation): Describe the new option. > * src/timeout.c (use_exit_status): A new global boolean to > enable the --exit-status behavior. Thanks. This looks fine. Did you consider calling it --preserve-exit-status? That seems more descriptive to me, since it preserves the exit status of the command that timeout runs. When I first saw --exit-status, I wondered if it should have an =3DN after it, by which to specify a specific number. > (usage): Describe the new option. > (main): Don't return EXIT_TIMEOUT of use_exit_status is set. > * tests/misc/timeout.sh: Add a test for the new option. > --- > doc/coreutils.texi | 6 ++++++ > src/timeout.c | 28 +++++++++++++++++++--------- > tests/misc/timeout.sh | 5 +++++ > 3 files changed, 30 insertions(+), 9 deletions(-) > > diff --git a/doc/coreutils.texi b/doc/coreutils.texi ... > @@ -214,6 +217,9 @@ Start COMMAND, and kill it if still running after DUR= ATION.\n\ > Mandatory arguments to long options are mandatory for short options too.= \n\ > "), stdout); > fputs (_("\ > + --exit-status\n\ > + exit with the same status as COMMAND even if the\n\ > + command timed out\n\ Slightly better: exit with the same status as COMMAND, even when the\n\ command times out\n\ From debbugs-submit-bounces@debbugs.gnu.org Mon Oct 29 05:57:08 2012 Received: (at 6308) by debbugs.gnu.org; 29 Oct 2012 09:57:08 +0000 Received: from localhost ([127.0.0.1]:37418 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TSm5k-0002ia-JV for submit@debbugs.gnu.org; Mon, 29 Oct 2012 05:57:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38507) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TSm5h-0002iS-Us for 6308@debbugs.gnu.org; Mon, 29 Oct 2012 05:57:07 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q9T9sdIX021554 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 29 Oct 2012 05:54:39 -0400 Received: from [10.36.116.63] (ovpn-116-63.ams2.redhat.com [10.36.116.63]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q9T9sZ69000429 (version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Mon, 29 Oct 2012 05:54:37 -0400 Message-ID: <508E525C.20208@draigBrady.com> Date: Mon, 29 Oct 2012 09:54:36 +0000 From: =?ISO-8859-1?Q?P=E1draig_Brady?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120615 Thunderbird/13.0.1 MIME-Version: 1.0 To: Jim Meyering Subject: Re: bug#6308: Preserve command exit code in timeout(3) References: <20121021203643.GA3624@kr.tuwien.ac.at> <50850FCE.80106@draigBrady.com> <20121022122726.GA5407@kr.tuwien.ac.at> <508DD12F.2050607@draigBrady.com> <87sj8xhdld.fsf@rho.meyering.net> In-Reply-To: <87sj8xhdld.fsf@rho.meyering.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by mx1.redhat.com id q9T9sdIX021554 X-Spam-Score: -4.2 (----) X-Debbugs-Envelope-To: 6308 Cc: 6308@debbugs.gnu.org, =?ISO-8859-1?Q?=C1ngel_?= =?ISO-8859-1?Q?Gonz=E1lez?= , Thomas Krennwallner 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: -4.2 (----) On 10/29/2012 08:44 AM, Jim Meyering wrote: > P=E1draig Brady wrote: > ... >> Subject: [PATCH] timeout: add --exit-status to always propagate the co= mmand's >> exit status >> >> It's useful for commands that support running for an indeterminite >> amount of time, to not return a specific timeout exit status (124), >> and instead let the command handle the timeout signal and return >> a status for the work done so far. >> >> * doc/coreutils.texi (timeout invocation): Describe the new option. >> * src/timeout.c (use_exit_status): A new global boolean to >> enable the --exit-status behavior. > > Thanks. This looks fine. > > Did you consider calling it --preserve-exit-status? > That seems more descriptive to me, since it preserves the exit > status of the command that timeout runs. > When I first saw --exit-status, I wondered if it should have an =3DN > after it, by which to specify a specific number. Yes I did. --preserve-exit-status is better, but worse because it's longer. Maybe split the difference with --preserve-status ? thanks, P=E1draig. From debbugs-submit-bounces@debbugs.gnu.org Mon Oct 29 06:10:04 2012 Received: (at 6308) by debbugs.gnu.org; 29 Oct 2012 10:10:04 +0000 Received: from localhost ([127.0.0.1]:37448 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TSmIE-00033B-Um for submit@debbugs.gnu.org; Mon, 29 Oct 2012 06:10:03 -0400 Received: from mx.meyering.net ([88.168.87.75]:37261) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TSmIB-00032g-T0 for 6308@debbugs.gnu.org; Mon, 29 Oct 2012 06:10:01 -0400 Received: from rho.meyering.net (rho [127.0.0.1]) by rho.meyering.net (Acme Bit-Twister) with ESMTP id 27D9460176; Mon, 29 Oct 2012 11:07:33 +0100 (CET) From: Jim Meyering To: =?iso-8859-1?Q?P=E1draig?= Brady Subject: Re: bug#6308: Preserve command exit code in timeout(3) In-Reply-To: <508E525C.20208@draigBrady.com> (=?iso-8859-1?Q?=22P=E1draig?= Brady"'s message of "Mon, 29 Oct 2012 09:54:36 +0000") References: <20121021203643.GA3624@kr.tuwien.ac.at> <50850FCE.80106@draigBrady.com> <20121022122726.GA5407@kr.tuwien.ac.at> <508DD12F.2050607@draigBrady.com> <87sj8xhdld.fsf@rho.meyering.net> <508E525C.20208@draigBrady.com> Date: Mon, 29 Oct 2012 11:07:33 +0100 Message-ID: <87mwz5h9qy.fsf@rho.meyering.net> Lines: 34 MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.2 (/) X-Debbugs-Envelope-To: 6308 Cc: 6308@debbugs.gnu.org, =?iso-8859-1?Q?=C1ngel?= =?iso-8859-1?Q?_Gonz=E1lez?= , Thomas Krennwallner 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: 0.2 (/) P=E1draig Brady wrote: > On 10/29/2012 08:44 AM, Jim Meyering wrote: >> P=E1draig Brady wrote: >> ... >>> Subject: [PATCH] timeout: add --exit-status to always propagate the com= mand's >>> exit status >>> >>> It's useful for commands that support running for an indeterminite >>> amount of time, to not return a specific timeout exit status (124), >>> and instead let the command handle the timeout signal and return >>> a status for the work done so far. >>> >>> * doc/coreutils.texi (timeout invocation): Describe the new option. >>> * src/timeout.c (use_exit_status): A new global boolean to >>> enable the --exit-status behavior. >> >> Thanks. This looks fine. >> >> Did you consider calling it --preserve-exit-status? >> That seems more descriptive to me, since it preserves the exit >> status of the command that timeout runs. >> When I first saw --exit-status, I wondered if it should have an =3DN >> after it, by which to specify a specific number. > > Yes I did. > --preserve-exit-status is better, but worse because it's longer. > Maybe split the difference with --preserve-status ? These days, I prefer more expressive option names. As long as a short prefix is unique, length doesn't really matter. Here, --p is enough. However, --preserve-status seems ok, too. There is precedent for using "status" to mean "exit status" with md5sum's --status option. Your call. From debbugs-submit-bounces@debbugs.gnu.org Mon Oct 29 07:13:13 2012 Received: (at 6308) by debbugs.gnu.org; 29 Oct 2012 11:13:13 +0000 Received: from localhost ([127.0.0.1]:37501 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TSnHN-000754-FY for submit@debbugs.gnu.org; Mon, 29 Oct 2012 07:13:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:20791) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TSnHL-00074x-9F for 6308@debbugs.gnu.org; Mon, 29 Oct 2012 07:13:12 -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 q9TBAi97024020 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 29 Oct 2012 07:10:45 -0400 Received: from [10.36.116.63] (ovpn-116-63.ams2.redhat.com [10.36.116.63]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q9TBAfIq026123 (version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Mon, 29 Oct 2012 07:10:43 -0400 Message-ID: <508E6430.5060000@draigBrady.com> Date: Mon, 29 Oct 2012 11:10:40 +0000 From: =?ISO-8859-1?Q?P=E1draig_Brady?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120615 Thunderbird/13.0.1 MIME-Version: 1.0 To: Jim Meyering Subject: Re: bug#6308: Preserve command exit code in timeout(3) References: <20121021203643.GA3624@kr.tuwien.ac.at> <50850FCE.80106@draigBrady.com> <20121022122726.GA5407@kr.tuwien.ac.at> <508DD12F.2050607@draigBrady.com> <87sj8xhdld.fsf@rho.meyering.net> <508E525C.20208@draigBrady.com> <87mwz5h9qy.fsf@rho.meyering.net> In-Reply-To: <87mwz5h9qy.fsf@rho.meyering.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by mx1.redhat.com id q9TBAi97024020 X-Spam-Score: -4.2 (----) X-Debbugs-Envelope-To: 6308 Cc: 6308@debbugs.gnu.org, =?ISO-8859-1?Q?=C1ngel_?= =?ISO-8859-1?Q?Gonz=E1lez?= , Thomas Krennwallner 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: -4.2 (----) On 10/29/2012 10:07 AM, Jim Meyering wrote: > These days, I prefer more expressive option names. As long as a short > prefix is unique, length doesn't really matter. Here, --p is enough. > However, --preserve-status seems ok, too. There is precedent for > using "status" to mean "exit status" with md5sum's --status option. > Your call. I've a slight preference for --preserve-status so. thanks, P=E1draig. From debbugs-submit-bounces@debbugs.gnu.org Sat Nov 03 21:59:40 2012 Received: (at 6308-done) by debbugs.gnu.org; 4 Nov 2012 01:59:40 +0000 Received: from localhost ([127.0.0.1]:47820 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TUpUx-0003U3-Bb for submit@debbugs.gnu.org; Sat, 03 Nov 2012 21:59:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:63268) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TUpUr-0003Tr-Em for 6308-done@debbugs.gnu.org; Sat, 03 Nov 2012 21:59:38 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qA41uY2K011152 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 3 Nov 2012 21:56:34 -0400 Received: from [10.36.116.18] (ovpn-116-18.ams2.redhat.com [10.36.116.18]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id qA41uUoR017997 (version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Sat, 3 Nov 2012 21:56:32 -0400 Message-ID: <5095CB4E.3000501@draigBrady.com> Date: Sun, 04 Nov 2012 01:56:30 +0000 From: =?ISO-8859-1?Q?P=E1draig_Brady?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120615 Thunderbird/13.0.1 MIME-Version: 1.0 To: Jim Meyering Subject: Re: bug#6308: Preserve command exit code in timeout(3) References: <20121021203643.GA3624@kr.tuwien.ac.at> <50850FCE.80106@draigBrady.com> <20121022122726.GA5407@kr.tuwien.ac.at> <508DD12F.2050607@draigBrady.com> <87sj8xhdld.fsf@rho.meyering.net> <508E525C.20208@draigBrady.com> <87mwz5h9qy.fsf@rho.meyering.net> <508E6430.5060000@draigBrady.com> In-Reply-To: <508E6430.5060000@draigBrady.com> Content-Type: multipart/mixed; boundary="------------020306090302080203030904" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-Spam-Score: -4.2 (----) X-Debbugs-Envelope-To: 6308-done Cc: =?ISO-8859-1?Q?=C1ngel_?= =?ISO-8859-1?Q?Gonz=E1lez?= , 6308-done@debbugs.gnu.org, Thomas Krennwallner 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.9 (------) This is a multi-part message in MIME format. --------------020306090302080203030904 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by mx1.redhat.com id qA41uY2K011152 On 10/29/2012 11:10 AM, P=E1draig Brady wrote: > On 10/29/2012 10:07 AM, Jim Meyering wrote: >> These days, I prefer more expressive option names. As long as a short >> prefix is unique, length doesn't really matter. Here, --p is enough. >> However, --preserve-status seems ok, too. There is precedent for >> using "status" to mean "exit status" with md5sum's --status option. >> Your call. > > I've a slight preference for --preserve-status so. I'm pushing the attached so marking this done. cheers, P=E1draig. --------------020306090302080203030904 Content-Type: text/x-patch; name="timeout--preserve-status.diff" Content-Disposition: attachment; filename="timeout--preserve-status.diff" Content-Transfer-Encoding: 7bit >From de2397fece839ce90f71e0624f5435755ad9ea01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81ngel=20Gonz=C3=A1lez?= Date: Mon, 29 Oct 2012 00:36:08 +0000 Subject: [PATCH] timeout: add --preserve-status to always propagate the exit status It's useful for commands that support running for an indeterminite amount of time, to not return a specific timeout exit status (124), and instead let the command handle the timeout signal and return a status for the work done so far. * doc/coreutils.texi (timeout invocation): Describe the new option. * src/timeout.c (preserve_status): A new global boolean to enable the --preserve-status behavior. (usage): Describe the new option. (main): Don't return EXIT_TIMEOUT of preserve_status is set. * tests/misc/timeout.sh: Add a test for the new option. --- doc/coreutils.texi | 6 ++++++ src/timeout.c | 28 +++++++++++++++++++--------- tests/misc/timeout.sh | 5 +++++ 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/doc/coreutils.texi b/doc/coreutils.texi index e2b1059..767a31e 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi @@ -15890,6 +15890,12 @@ The program accepts the following options. Also see @ref{Common options}. Options must precede operands. @table @samp +@item --preserve-status +@opindex --preserve-status +Return the exit status of the managed @var{command} on timeout, rather than +a specific exit status indicating a timeout. This is useful if the +managed @var{command} supports running for an indeterminite amount of time. + @item --foreground @opindex --foreground Don't create a separate background program group, so that diff --git a/src/timeout.c b/src/timeout.c index 4ce18ad..02d21c5 100644 --- a/src/timeout.c +++ b/src/timeout.c @@ -81,12 +81,14 @@ static int timed_out; static int term_signal = SIGTERM; /* same default as kill command. */ static int monitored_pid; static double kill_after; -static bool foreground; /* whether to use another program group. */ +static bool foreground; /* whether to use another program group. */ +static bool preserve_status; /* whether to use a timeout status or not. */ /* for long options with no corresponding short option, use enum */ enum { - FOREGROUND_OPTION = CHAR_MAX + 1 + FOREGROUND_OPTION = CHAR_MAX + 1, + PRESERVE_STATUS_OPTION }; static struct option const long_options[] = @@ -94,6 +96,7 @@ static struct option const long_options[] = {"kill-after", required_argument, NULL, 'k'}, {"signal", required_argument, NULL, 's'}, {"foreground", no_argument, NULL, FOREGROUND_OPTION}, + {"preserve-status", no_argument, NULL, PRESERVE_STATUS_OPTION}, {GETOPT_HELP_OPTION_DECL}, {GETOPT_VERSION_OPTION_DECL}, {NULL, 0, NULL, 0} @@ -214,6 +217,9 @@ Start COMMAND, and kill it if still running after DURATION.\n\ Mandatory arguments to long options are mandatory for short options too.\n\ "), stdout); fputs (_("\ + --preserve-status\n\ + exit with the same status as COMMAND, even when the\n\ + command times out\n\ --foreground\n\ When not running timeout directly from a shell prompt,\n\ allow COMMAND to read from the TTY and receive TTY signals.\n\ @@ -235,12 +241,12 @@ DURATION is a floating point number with an optional suffix:\n\ or 'd' for days.\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. If the\n\ -KILL (9) signal is sent, the exit status is 128+9 rather than 124.\n"), stdout); +If the command times out, and --preserve-status is 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. It may be necessary\n\ +to use the KILL (9) signal, since this signal cannot be caught, in which\n\ +case the exit status is 128+9 rather than 124.\n"), stdout); emit_ancillary_info (); } exit (status); @@ -376,6 +382,10 @@ main (int argc, char **argv) foreground = true; break; + case PRESERVE_STATUS_OPTION: + preserve_status = true; + break; + case_GETOPT_HELP_CHAR; case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); @@ -470,7 +480,7 @@ main (int argc, char **argv) } } - if (timed_out) + if (timed_out && !preserve_status) return EXIT_TIMEDOUT; else return status; diff --git a/tests/misc/timeout.sh b/tests/misc/timeout.sh index 57a4e15..66d6956 100755 --- a/tests/misc/timeout.sh +++ b/tests/misc/timeout.sh @@ -36,6 +36,11 @@ test $? = 2 || fail=1 timeout 1 sleep 10 test $? = 124 || fail=1 +# exit status propagation even on timeout +timeout --preserve-status 1 sleep 10 +# exit status should be 128+TERM +test $? = 124 && fail=1 + # kill delay. Note once the initial timeout triggers, # the exit status will be 124 even if the command # exits on its own accord. -- 1.7.6.4 --------------020306090302080203030904-- From unknown Tue Aug 12 04:07:02 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sun, 02 Dec 2012 12:24:03 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator