Package: timeout
Version: 1.11-6.5
Severity: normal
Tags: patch

The timeout program  does not return the exit status of the program it runs, 
although it is documented to do so.

The problem is that wait(2) returns a 16-bit integer, with the exit status in 
the high bits and the signal information in the low bits.  This value 
is passed unmodified to exit(2), which expects an 8-bit integer with just the 
exit status.

This is fixed in the latest version of The Coroner's Toolkit, by using 
WEXITSTATUS and WTERMSIG to compute an exit value.

This patch modifies the 1.11 version of timeout included in Lenny to have the 
same behavior.

-- System Information:
Debian Release: 5.0.4
  APT prefers oldstable
  APT policy: (500, 'oldstable')
Architecture: i386 (i686)

Kernel: Linux 2.6.21.7-2.fc8xen (SMP w/1 CPU core)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages timeout depends on:
ii  libc6                       2.7-18lenny2 GNU C Library: Shared libraries

timeout recommends no packages.

timeout suggests no packages.

-- no debconf information
Binary files tct-1.11/bin/timeout and tct-1.11-sg/bin/timeout differ
diff -ur tct-1.11/src/misc/timeout.c tct-1.11-sg/src/misc/timeout.c
--- tct-1.11/src/misc/timeout.c	2001-09-09 17:46:10.000000000 -0400
+++ tct-1.11-sg/src/misc/timeout.c	2011-08-24 17:27:22.000000000 -0400
@@ -30,6 +30,7 @@
 /* System libraries. */
 
 #include <sys/types.h>
+#include <sys/wait.h>
 #include <signal.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -103,6 +104,6 @@
 	alarm(time_to_run);
 	while ((pid = wait(&status)) != -1 && pid != child_pid)
 	     /* void */ ;
-	return (pid == child_pid ? status : -1);
+	return (pid == child_pid ? WEXITSTATUS(status) | WTERMSIG(status) : -1);
     }
 }

Reply via email to