bugGNU Time - Bugs: bug #45133, time exit status for killed...


bug #45133: time exit status for killed subprocess

Submitter:  Andrei Gaponenko <andr>
Submitted:  Mon 18 May 2015 03:43:16 PM UTC
Category:  None Severity:  3 - Normal
Item Group:  None Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open
* Mandatory Fields

Add a New Comment Rich Markup

Mon 18 May 2015 03:43:16 PM UTC, original submission:  


If a process monitored by the GNU time utility is killed, time returns the signal number as the status code.   I suggest to return 128+signal instead for such cases, consistent with signal handling in bash.

If one runs a program in a batch system, and the program is killed by a signal, the exit status of the batch script indicates the signal kill, providing valuable diagnostic.  Instead of running


directly from the shell, I like running

/usr/bin/time program

where /usr/bin/time is the GNU time utility.  That provides useful information about resource usage.  However when the program is killed by a signal, the current behavior of the time utility masks that fact and makes it look like the program exited voluntarily with a non-zero exit code.   The patch below would address the issue.


diff --git a/time.c b/time.c
index ee13dd7..fa35dae 100644
--- a/time.c
+++ b/time.c
@@ -646,7 +646,7 @@ main (argc, argv)
   if (WIFSTOPPED (res.waitstatus))
     exit (WSTOPSIG (res.waitstatus));
   else if (WIFSIGNALED (res.waitstatus))
-    exit (WTERMSIG (res.waitstatus));
+    exit (128 + WTERMSIG (res.waitstatus));
   else if (WIFEXITED (res.waitstatus))
     exit (WEXITSTATUS (res.waitstatus));

Andrei Gaponenko <andr>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by andr (Submitted the item)

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.


    No changes have been made to this item

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code