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

 
 

bug #45133: time exit status for killed subprocess

Submitted by:  Andrei Gaponenko <andr>
Submitted on:  Mon 18 May 2015 03:43:16 PM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: NoneStatus: None
Privacy: PublicAssigned to: None
Open/Closed: Open

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

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

Hello,

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

program

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.

Andrei

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 File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    No Changes Have Been Made to This Item

    Back to the top


    Powered by Savane 3.1-cleanup1