reassign 522686 libc0.1-dev
retitle 522686 [kfreebsd-*] <bits/waitstatus.h> __WIFCONTINUED userland 
definition doesn't match kernel
kthxbye

Hi,

job control in bash is broken because jobs.c:waitchld() expects the Linux
__WIFCONTINUED response (status == 0xffff) and erroneously assumes the job
to be dead when BSD reports status == 0x13, i.e. BSD SIGCONT.

Cf. FreeBSD kernel 7.1, sys/wait.h:

] #define _WSTATUS(x)     (_W_INT(x) & 0177)
] #define _WSTOPPED       0177            /* _WSTATUS if process is stopped */
] #define WIFSTOPPED(x)   (_WSTATUS(x) == _WSTOPPED)
] #define WSTOPSIG(x)     (_W_INT(x) >> 8)
] #define WIFSIGNALED(x)  (_WSTATUS(x) != _WSTOPPED && _WSTATUS(x) != 0)
] #define WTERMSIG(x)     (_WSTATUS(x))
] #define WIFEXITED(x)    (_WSTATUS(x) == 0)
] #define WEXITSTATUS(x)  (_W_INT(x) >> 8)
] #define WIFCONTINUED(x) (x == 0x13)     /* 0x13 == SIGCONT */
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^

This should be fixed in libc0.1-dev's <bits/waitstatus.h>. To get a working
bash in the meantime, you can apply the attached patch to the current
bash4 source package. (Will probably work with minor modifications for
bash3, too.)


Regards,

Jan
diff -u bash-4.0/debian/rules bash-4.0/debian/rules
--- bash-4.0/debian/rules
+++ bash-4.0/debian/rules
@@ -566,6 +566,7 @@
        exec-redirections-man \
        bash-aliases-repeat \
        CVE-2008-5374 \
+       jobcontrol
 
 ifeq ($(with_gfdl),yes)
   debian_patches += \
only in patch2:
unchanged:
--- bash-4.0.orig/debian/patches/jobcontrol.dpatch
+++ bash-4.0/debian/patches/jobcontrol.dpatch
@@ -0,0 +1,33 @@
+#! /bin/sh -e
+
+if [ $# -eq 3 -a "$2" = '-d' ]; then
+    pdir="-d $3"
+elif [ $# -ne 1 ]; then
+    echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+    exit 1
+fi
+case "$1" in
+    -patch) patch $pdir -f --no-backup-if-mismatch -p0 < $0;;
+    -unpatch) patch $pdir -f --no-backup-if-mismatch -R -p0 < $0;;
+    *)
+       echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+       exit 1
+esac
+exit 0
+
+# DP: fix jobcontrol until the WIFCONTINUED macro is fixed in libc0.1-dev
+# DP: Jan Christoph Nordholz  <[email protected]>  2009-04-13
+
+--- jobs.c.orig        2009-01-29 23:09:49.000000000 +0100
++++ jobs.c     2009-04-13 01:55:54.019583928 +0200
+@@ -134,6 +134,10 @@
+ #if !defined (WIFCONTINUED)
+ #  define WIFCONTINUED(s)     (0)
+ #endif
++#if defined(__FreeBSD_kernel__)
++# undef WIFCONTINUED
++# define WIFCONTINUED(status) (WTERMSIG(status) == SIGCONT)
++#endif
+ 
+ /* The number of additional slots to allocate when we run out. */
+ #define JOB_SLOTS 8

Attachment: signature.asc
Description: Digital signature

Reply via email to