Package: timelimit
Version: 1.1-3
Severity: wishlist
Tags: patch

Hi,

timelimit would be much more useful if it returned the child's exit
code instead of 0. The patch below implements that, please consider
applying it.


debdiff timelimit_1.1-3.dsc timelimit_1.1-3.1.dsc
 timelimit-1.1/debian/changelog |    6 ++++++
 timelimit.c                    |   23 +++++++++++++++--------
 config.h                       |    1 +
 3 files changed, 22 insertions(+), 8 deletions(-)

diff -u timelimit-1.1/debian/changelog timelimit-1.1/debian/changelog
--- timelimit-1.1/debian/changelog
+++ timelimit-1.1/debian/changelog
@@ -1,3 +1,9 @@
+timelimit (1.1-3.1) unstable; urgency=low
+
+  * Return the child process exit code instead of always exiting with 0.
+
+ -- Christoph Berg <[EMAIL PROTECTED]>  Sun, 10 Aug 2008 20:25:45 -0300
+
 timelimit (1.1-3) unstable; urgency=low
 
   * Fix the watchfile
only in patch2:
unchanged:
--- timelimit-1.1.orig/timelimit.c
+++ timelimit-1.1/timelimit.c
@@ -55,7 +55,7 @@
 static void    usage(void);
 
 static void    init(int, char *[]);
-static void    doit(char *[]);
+static int     doit(char *[]);
 static void    child(char *[]);
 static void    terminated(const char *);
 
@@ -227,7 +227,7 @@
 #endif /* HAVE_SIGACTION */
 }
     
-static void
+static int
 doit(char *argv[]) {
        pid_t pid;
 
@@ -253,8 +253,12 @@
        alarm(0);
 
        /* send the warning signal */
-       if (fdone)
-               return;
+       if (fdone) {
+               int status;
+               waitpid(pid, &status, WNOHANG);
+               return WIFEXITED(status) ? WEXITSTATUS(status) :
+                       WIFSIGNALED(status) ? WTERMSIG(status)+128 : 1;
+       }
        if (fsig)
                terminated("run");
        falarm = 0;
@@ -279,8 +283,12 @@
        alarm(0);
 
        /* send the kill signal */
-       if (fdone)
-               return;
+       if (fdone) {
+               int status;
+               waitpid(pid, &status, WNOHANG);
+               return WIFEXITED(status) ? WEXITSTATUS(status) :
+                       WIFSIGNALED(status) ? WTERMSIG(status)+128 : 1;
+       }
        if (fsig)
                terminated("grace");
        if (!quiet)
@@ -308,6 +316,5 @@
        init(argc, argv);
        argc -= optind;
        argv += optind;
-       doit(argv);
-       return (EX_OK);
+       return doit(argv);
 }
only in patch2:
unchanged:
--- timelimit-1.1.orig/config.h
+++ timelimit-1.1/config.h
@@ -31,6 +31,7 @@
 /* we hope all OS's have those..*/
 #include <sys/types.h>
 #include <sys/signal.h>
+#include <sys/wait.h>
 
 #include <signal.h>
 #include <stdarg.h>

Christoph
-- 
[EMAIL PROTECTED] | http://www.df7cb.de/

Attachment: signature.asc
Description: Digital signature

Reply via email to