[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: SIGSTOP and bash's time built-in

From: Chet Ramey
Subject: Re: SIGSTOP and bash's time built-in
Date: Mon, 2 Nov 2015 07:50:49 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Thunderbird/38.3.0

On 10/30/15 3:34 PM, Stefan Tauner wrote:
> On Fri, 30 Oct 2015 14:00:10 -0400
> Chet Ramey <address@hidden> wrote:
>> On 10/30/15 12:50 PM, Mike Frysinger wrote:
>>> On 26 Oct 2015 16:59, Stefan Tauner wrote:
>>>> I was creating some exercises for my students when I noticed very
>>>> strange behavior of the time built-in when sending SIGSTOP to a timed
>>>> command interactively (via ^Z):
>>> you could always install the dedicated time program and then do:
>>> $ /usr/bin/time sleep 5
>>> that'll handle ^Z and such
>> It's probably already installed, and \time will work to invoke it.
> Yes of course and this is the workaround I suggested to my students,
> but this is still a major bug IMHO. The output of time(1) is defined in
> POSIX as "[…]time between invocation of utility and its termination."
> (http://pubs.opengroup.org/onlinepubs/9699919799/utilities/time.html).
> I am not aware of any exceptions...(?) so the bash built-in clearly
> breaks this major aspect of the defined behavior.

It's not a builtin command.  It's a commnand modifier -- that's what
allows it to time pipelines and shell builtins, which an external
command cannot do.

The fact that it isn't tied to job control is technically a bug, but a
minor one.  It comes up occasionally as a problem.

This is on the list of things to look at, but is not a high priority.
If you'd like to take a shot at modifying bash to support this behavior,
you'd probably have to start with time_command() and go into augmenting
the job structure with timing info.

If you're interested in a survey of shells' implementations of `time',
bash, ksh93, and mksh print timing statistics when the process being
timed is suspended, dash and its siblings don't implement `time' at all,
and zsh behaves as you'd like.


``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/

reply via email to

[Prev in Thread] Current Thread [Next in Thread]