bug-bash
[Top][All Lists]
Advanced

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

Re: BUG: "time" command adding to wrong process.


From: Chet Ramey
Subject: Re: BUG: "time" command adding to wrong process.
Date: Wed, 08 Jan 2014 10:50:47 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Thunderbird/24.1.1

On 1/8/14 7:00 AM, James Bonfield wrote:

> Bash Version: 4.1
> Patch Level: 5
> Release Status: release
> 
> Description:
>       If I have a process running in the background that finishes
>       while I have a foreground process being timed using the
>       builtin time command, then the CPU time of the background task
>       is erroneously added on to the foreground task. This does not
>       happen if the background task ends after the foreground task.

This is simply an artifact of how process time accounting is done.  The
time consumed by children of the current process is modified when a child
process exits.  The command timing code just looks at the difference in
the time alloted to the shell process and its children before and after
executing the timed command, and computes the time taken by subtracting
before from after.

It's more difficult to get timing information for other individual
processes, and changing the code to do that would interfere with the
ability to time builtins and other shell commands.

Chet

-- 
``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/



reply via email to

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