GNU bug report logs - #6308
Preserve command exit code in timeout(3)

Previous Next

Package: coreutils;

Reported by: "Ángel González" <keisial <at> gmail.com>

Date: Sun, 30 May 2010 00:23:01 UTC

Severity: normal

Tags: moreinfo

Done: Pádraig Brady <P <at> draigBrady.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 6308 in the body.
You can then email your comments to 6308 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org:
bug#6308; Package coreutils. (Sun, 30 May 2010 00:23:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to "Ángel González" <keisial <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Sun, 30 May 2010 00:23:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: "Ángel González" <keisial <at> gmail.com>
To: bug-coreutils <bug-coreutils <at> gnu.org>
Subject: Preserve command exit code in timeout(3)
Date: Sun, 30 May 2010 02:15:20 +0200
[Message part 1 (text/plain, inline)]
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.

[timeout-exit-status.patch (text/x-patch, attachment)]

Information forwarded to owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org:
bug#6308; Package coreutils. (Sun, 30 May 2010 12:30:03 GMT) Full text and rfc822 format available.

Message #8 received at 6308 <at> debbugs.gnu.org (full text, mbox):

From: Pádraig Brady <P <at> draigBrady.com>
To: Ángel González <keisial <at> gmail.com>
Cc: 6308 <at> debbugs.gnu.org
Subject: Re: bug#6308: Preserve command exit code in timeout(3)
Date: Sun, 30 May 2010 13:26:01 +0100
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.




Information forwarded to bug-coreutils <at> gnu.org:
bug#6308; Package coreutils. (Sun, 13 Nov 2011 11:55:01 GMT) Full text and rfc822 format available.

Message #11 received at 6308 <at> debbugs.gnu.org (full text, mbox):

From: Jim Meyering <jim <at> meyering.net>
To: Ángel González <keisial <at> gmail.com>
Cc: Pádraig Brady <P <at> draigBrady.com>, 6308 <at> debbugs.gnu.org
Subject: Re: bug#6308: Preserve command exit code in timeout(3)
Date: Sun, 13 Nov 2011 12:54:18 +0100
tags 6308 moreinfo
thanks

Pádraig Brady wrote:
> 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.

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...




Added tag(s) moreinfo. Request was from Jim Meyering <jim <at> meyering.net> to control <at> debbugs.gnu.org. (Sun, 13 Nov 2011 11:55:01 GMT) Full text and rfc822 format available.

Information forwarded to bug-coreutils <at> gnu.org:
bug#6308; Package coreutils. (Mon, 22 Oct 2012 01:57:03 GMT) Full text and rfc822 format available.

Message #16 received at 6308 <at> debbugs.gnu.org (full text, mbox):

From: Thomas Krennwallner <tkren <at> kr.tuwien.ac.at>
To: Jim Meyering <jim <at> meyering.net>
Cc: Pádraig Brady <P <at> draigBrady.com>,
	Ángel González <keisial <at> gmail.com>,
	6308 <at> debbugs.gnu.org
Subject: Re: bug#6308: Preserve command exit code in timeout(3)
Date: Sun, 21 Oct 2012 22:36:43 +0200
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.

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

-- 
Thomas Krennwallner
University assistant
.
TU Wien - Vienna University of Technology
Institute of Information Systems
Favoritenstrasse 9-11, 1040 Wien, Austria
.
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/
.
DVR: 0005886




Information forwarded to bug-coreutils <at> gnu.org:
bug#6308; Package coreutils. (Mon, 22 Oct 2012 09:23:01 GMT) Full text and rfc822 format available.

Message #19 received at 6308 <at> debbugs.gnu.org (full text, mbox):

From: Pádraig Brady <P <at> draigBrady.com>
To: Thomas Krennwallner <tkren <at> kr.tuwien.ac.at>
Cc: Ángel González <keisial <at> gmail.com>,
	Jim Meyering <jim <at> meyering.net>, 6308 <at> debbugs.gnu.org
Subject: Re: bug#6308: Preserve command exit code in timeout(3)
Date: Mon, 22 Oct 2012 10:20:14 +0100
On 10/21/2012 09:36 PM, Thomas Krennwallner wrote:
> 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.
>
> 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ádraig.




Information forwarded to bug-coreutils <at> gnu.org:
bug#6308; Package coreutils. (Mon, 22 Oct 2012 12:30:02 GMT) Full text and rfc822 format available.

Message #22 received at 6308 <at> debbugs.gnu.org (full text, mbox):

From: Thomas Krennwallner <tkren <at> kr.tuwien.ac.at>
To: Pádraig Brady <P <at> draigBrady.com>
Cc: Ángel González <keisial <at> gmail.com>,
	Jim Meyering <jim <at> meyering.net>, 6308 <at> debbugs.gnu.org
Subject: Re: bug#6308: Preserve command exit code in timeout(3)
Date: Mon, 22 Oct 2012 14:27:26 +0200
On Mon Oct 22, 2012 10:20:14AM +0100, Pádraig 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 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

-- 
Thomas Krennwallner
University assistant
.
TU Wien - Vienna University of Technology
Institute of Information Systems
Favoritenstrasse 9-11, 1040 Wien, Austria
.
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/
.
DVR: 0005886




Information forwarded to bug-coreutils <at> gnu.org:
bug#6308; Package coreutils. (Mon, 29 Oct 2012 00:46:02 GMT) Full text and rfc822 format available.

Message #25 received at 6308 <at> debbugs.gnu.org (full text, mbox):

From: Pádraig Brady <P <at> draigBrady.com>
To: Thomas Krennwallner <tkren <at> kr.tuwien.ac.at>
Cc: Ángel González <keisial <at> gmail.com>,
	Jim Meyering <jim <at> meyering.net>, 6308 <at> debbugs.gnu.org
Subject: Re: bug#6308: Preserve command exit code in timeout(3)
Date: Mon, 29 Oct 2012 00:43:27 +0000
[Message part 1 (text/plain, inline)]
On 10/22/2012 01:27 PM, Thomas Krennwallner wrote:
> On Mon Oct 22, 2012 10:20:14AM +0100, Pádraig 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 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!

Proposed patch is attached.

thanks,
Pádraig.
[timeout-exit-status.diff (text/x-patch, attachment)]

Information forwarded to bug-coreutils <at> gnu.org:
bug#6308; Package coreutils. (Mon, 29 Oct 2012 08:38:01 GMT) Full text and rfc822 format available.

Message #28 received at 6308 <at> debbugs.gnu.org (full text, mbox):

From: Thomas Krennwallner <tkren <at> kr.tuwien.ac.at>
To: Pádraig Brady <P <at> draigBrady.com>
Cc: Ángel González <keisial <at> gmail.com>,
	Jim Meyering <jim <at> meyering.net>, 6308 <at> debbugs.gnu.org
Subject: Re: bug#6308: Preserve command exit code in timeout(3)
Date: Mon, 29 Oct 2012 09:34:49 +0100
On Mon Oct 29, 2012 12:43:27AM +0000, Pádraig Brady wrote:
> On 10/22/2012 01:27 PM, Thomas Krennwallner wrote:
> >On Mon Oct 22, 2012 10:20:14AM +0100, Pádraig 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 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!
> 
> Proposed patch is attached.

I've tried it and it works flawlessly.  Thank you!

Best,
TK

-- 
Thomas Krennwallner
University assistant
.
TU Wien - Vienna University of Technology
Institute of Information Systems
Favoritenstrasse 9-11, 1040 Wien, Austria
.
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/
.
DVR: 0005886




Information forwarded to bug-coreutils <at> gnu.org:
bug#6308; Package coreutils. (Mon, 29 Oct 2012 08:47:02 GMT) Full text and rfc822 format available.

Message #31 received at 6308 <at> debbugs.gnu.org (full text, mbox):

From: Jim Meyering <jim <at> meyering.net>
To: Pádraig Brady <P <at> draigBrady.com>
Cc: 6308 <at> debbugs.gnu.org,
	Ángel González <keisial <at> gmail.com>,
	Thomas Krennwallner <tkren <at> kr.tuwien.ac.at>
Subject: Re: bug#6308: Preserve command exit code in timeout(3)
Date: Mon, 29 Oct 2012 09:44:30 +0100
Pádraig Brady wrote:
...
> 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.

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 =N
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 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\

Slightly better:

                    exit with the same status as COMMAND, even when the\n\
                    command times out\n\




Information forwarded to bug-coreutils <at> gnu.org:
bug#6308; Package coreutils. (Mon, 29 Oct 2012 09:58:02 GMT) Full text and rfc822 format available.

Message #34 received at 6308 <at> debbugs.gnu.org (full text, mbox):

From: Pádraig Brady <P <at> draigBrady.com>
To: Jim Meyering <jim <at> meyering.net>
Cc: 6308 <at> debbugs.gnu.org,
	Ángel González <keisial <at> gmail.com>,
	Thomas Krennwallner <tkren <at> kr.tuwien.ac.at>
Subject: Re: bug#6308: Preserve command exit code in timeout(3)
Date: Mon, 29 Oct 2012 09:54:36 +0000
On 10/29/2012 08:44 AM, Jim Meyering wrote:
> Pádraig Brady wrote:
> ...
>> 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.
>
> 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 =N
> 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ádraig.




Information forwarded to bug-coreutils <at> gnu.org:
bug#6308; Package coreutils. (Mon, 29 Oct 2012 10:11:02 GMT) Full text and rfc822 format available.

Message #37 received at 6308 <at> debbugs.gnu.org (full text, mbox):

From: Jim Meyering <jim <at> meyering.net>
To: Pádraig Brady <P <at> draigBrady.com>
Cc: 6308 <at> debbugs.gnu.org,
	Ángel González <keisial <at> gmail.com>,
	Thomas Krennwallner <tkren <at> kr.tuwien.ac.at>
Subject: Re: bug#6308: Preserve command exit code in timeout(3)
Date: Mon, 29 Oct 2012 11:07:33 +0100
Pádraig Brady wrote:

> On 10/29/2012 08:44 AM, Jim Meyering wrote:
>> Pádraig Brady wrote:
>> ...
>>> 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.
>>
>> 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 =N
>> 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.




Information forwarded to bug-coreutils <at> gnu.org:
bug#6308; Package coreutils. (Mon, 29 Oct 2012 11:14:02 GMT) Full text and rfc822 format available.

Message #40 received at 6308 <at> debbugs.gnu.org (full text, mbox):

From: Pádraig Brady <P <at> draigBrady.com>
To: Jim Meyering <jim <at> meyering.net>
Cc: 6308 <at> debbugs.gnu.org,
	Ángel González <keisial <at> gmail.com>,
	Thomas Krennwallner <tkren <at> kr.tuwien.ac.at>
Subject: Re: bug#6308: Preserve command exit code in timeout(3)
Date: Mon, 29 Oct 2012 11:10:40 +0000
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ádraig.




Reply sent to Pádraig Brady <P <at> draigBrady.com>:
You have taken responsibility. (Sun, 04 Nov 2012 02:00:02 GMT) Full text and rfc822 format available.

Notification sent to "Ángel González" <keisial <at> gmail.com>:
bug acknowledged by developer. (Sun, 04 Nov 2012 02:00:02 GMT) Full text and rfc822 format available.

Message #45 received at 6308-done <at> debbugs.gnu.org (full text, mbox):

From: Pádraig Brady <P <at> draigBrady.com>
To: Jim Meyering <jim <at> meyering.net>
Cc: Ángel González <keisial <at> gmail.com>,
	6308-done <at> debbugs.gnu.org, Thomas Krennwallner <tkren <at> kr.tuwien.ac.at>
Subject: Re: bug#6308: Preserve command exit code in timeout(3)
Date: Sun, 04 Nov 2012 01:56:30 +0000
[Message part 1 (text/plain, inline)]
On 10/29/2012 11:10 AM, Pádraig 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ádraig.
[timeout--preserve-status.diff (text/x-patch, attachment)]

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 02 Dec 2012 12:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 12 years and 204 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.