timeout fix for linux

Keresztfalvi Laszlo <[email protected]> Fri, 19 Jan 2007 11:37:44 +0100
Newsgroups gmane.comp.security.forensics.tct
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--------------060402080205000505060400
Content-Type: text/plain; charset=ISO-8859-2; format=flowed
Content-Transfer-Encoding: 7bit

Hello,

since I did not find other address to send a patch, here it is:

in src/misc/timeout.c (at least on Linux):

#include <sys/wait.h> and returning WEXITSTATUS(status) is required to correctly return the executed command's 
exit value.

Best regards,
Laszlo

--------------060402080205000505060400
Content-Type: text/x-patch;
 name="timeout.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="timeout.patch"

diff -ru tct-1.16/src/misc/timeout.c tct-1.16-fixed/src/misc/timeout.c
--- tct-1.16/src/misc/timeout.c	2004-10-18 16:59:31.000000000 +0200
+++ tct-1.16-fixed/src/misc/timeout.c	2007-01-19 11:03:58.000000000 +0100
@@ -34,6 +34,7 @@
 /* System libraries. */
 
 #include <sys/types.h>
+#include <sys/wait.h>
 #include <signal.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -107,6 +108,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) : -1);
     }
 }

--------------060402080205000505060400--