Package: timelimit
Version: 1.4-2
Severity: normal
Tags: patch

Returning signal+128 does *not* tell the invoking shell that the
program terminated by a signal.  Quote from
<http://www.cons.org/cracauer/sigint.html>:

        You cannot "fake" the proper exit status by an exit(3) with a
        special numeric value, even if you look up the numeric value
        for your system.  People often assume this since the manuals
        for shells often list some return value for exactly this.  But
        this is just a naming convention for your shell script.  It
        does not work from one UNIX API program to another.  The real
        information "did I exit on a signal yes/no" it not contained
        in the returned numeric value, it just looks that way in a
        shell which has just cooked up what the Unix API returned.

Patch:

--- timelimit-1.4/timelimit.c.~1~       2008-11-12 10:20:39.000000000 +0100
+++ timelimit-1.4/timelimit.c   2009-09-19 22:47:48.000000000 +0200
@@ -318,8 +318,29 @@
                    (long)pid);
        if (WIFEXITED(status))
                return (WEXITSTATUS(status));
-       else if (WIFSIGNALED(status))
-               return (WTERMSIG(status) + 128);
+       else if (WIFSIGNALED(status)) {
+#ifdef HAVE_SIGACTION
+               struct sigaction act;
+               
+               memset(&act, 0, sizeof(act));
+               act.sa_handler = SIG_DFL;
+               act.sa_flags = 0;
+               if (sigaction(WTERMSIG(status), &act, NULL) < 0) {
+                       err(EX_OSERR, "restoring signal handler for %d",
+                          WTERMSIG(status));
+                       abort();
+               }
+#else  /* HAVE_SIGACTION */
+               if (signal(sig, SIG_DFL) == SIG_ERR) {
+                       err(EX_OSERR, "restoring signal handler for %d",
+                          WTERMSIG(status));
+                       abort();
+               }
+#endif /* HAVE_SIGACTION */
+               raise(WTERMSIG(status));
+               while (1)
+                       pause();
+       }
        else
                return (EX_OSERR);
 }

-- System Information:
Debian Release: 5.0.3
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.26-2-686
Locale: LANG=C, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)

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

timelimit recommends no packages.

-- no debconf information



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to