[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: |
Thu, 29 Oct 2015 20:42:31 -0400 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 |
On 10/26/15 11:59 AM, Stefan Tauner wrote:
> Hi,
>
> 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):
>
> $ time sleep 5
> ^Z
> [1]+ Stopped sleep 5
>
> real 0m0.880s
> user 0m0.002s
> sys 0m0.000s
[...]
> I have briefly looked at the code... but there are way too much
> recursions in execute_pipeline() and signal handling all over the place
> that I'd rather not touch it yet. :) However, if you'd give me some
> pointers I can look into it.
If you look at time_command(), you'll see that it prints timing statistics
when execute_command_internal() returns. However, that will return when
the foreground job changes state (since that indicates that the shell
should read and execute another command). The shell isn't structured well
to discover at this point that the most recent job has been suspended, nor
are there enough hooks to print timing statistics when the command is
restarted and finally completes.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU chet@case.edu http://cnswww.cns.cwru.edu/~chet/