aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2010-08-15 18:55:24 -0400
committerMike Frysinger <vapier@gentoo.org>2010-08-15 18:55:24 -0400
commitb3e79e5912f0a40248d60142c07d0bf3c36fd4ec (patch)
tree0724b84a2c8c1a224cc8220a295c2e7a60e342ed /tests
parentlibsandbox: disable sparc ptrace until it can be debugged further (diff)
downloadsandbox-b3e79e5912f0a40248d60142c07d0bf3c36fd4ec.tar.gz
sandbox-b3e79e5912f0a40248d60142c07d0bf3c36fd4ec.tar.bz2
sandbox-b3e79e5912f0a40248d60142c07d0bf3c36fd4ec.zip
libsandbox: don't swallow SIGCHLD notifications
When tracing static processes, the original implementation included code that would always swallow SIGCHLD. Much has changed since then, and it doesn't seem to be needed anymore, and it is certainly breaking a few packages. So drop it, add some tests, and if it causes a regression in the future, we can look at it then (with an actual test case). URL: http://bugs.gentoo.org/289963 Reported-by: Joeri Capens <joeri@capens.net> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am6
-rwxr-xr-xtests/script-8.sh6
-rw-r--r--tests/script.at1
-rw-r--r--tests/sigsuspend-zsh_static_tst.c1
-rw-r--r--tests/sigsuspend-zsh_tst.c46
5 files changed, 58 insertions, 2 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 5f9702c..9a6432d 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -61,14 +61,16 @@ check_PROGRAMS = \
\
getcwd-gnulib_tst \
libsigsegv_tst \
- sb_printf_tst
+ sb_printf_tst \
+ sigsuspend-zsh_tst \
+ sigsuspend-zsh_static_tst
dist_check_SCRIPTS = \
$(wildcard *-?.sh) \
script-0 \
trace-0
-AM_LDFLAGS = `expr $@ : .*_static- >/dev/null && echo -all-static`
+AM_LDFLAGS = `expr $@ : .*_static >/dev/null && echo -all-static`
sb_printf_tst_CFLAGS = -I$(top_srcdir)/libsbutil -I$(top_srcdir)/libsbutil/include
sb_printf_tst_LDADD = $(top_builddir)/libsbutil/libsbutil.la
diff --git a/tests/script-8.sh b/tests/script-8.sh
new file mode 100755
index 0000000..8ad65f8
--- /dev/null
+++ b/tests/script-8.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+# make sure tracing doesnt swallow valid SIGCHLD events
+[ "${at_xfail}" = "yes" ] && exit 77 # see script-0
+
+sigsuspend-zsh_tst || exit 1
+sigsuspend-zsh_static_tst || exit 2
diff --git a/tests/script.at b/tests/script.at
index e76c782..9e8e900 100644
--- a/tests/script.at
+++ b/tests/script.at
@@ -5,3 +5,4 @@ SB_CHECK(4)
SB_CHECK(5)
SB_CHECK(6,,,8)
SB_CHECK(7)
+SB_CHECK(8)
diff --git a/tests/sigsuspend-zsh_static_tst.c b/tests/sigsuspend-zsh_static_tst.c
new file mode 100644
index 0000000..076aed5
--- /dev/null
+++ b/tests/sigsuspend-zsh_static_tst.c
@@ -0,0 +1 @@
+#include "sigsuspend-zsh_tst.c"
diff --git a/tests/sigsuspend-zsh_tst.c b/tests/sigsuspend-zsh_tst.c
new file mode 100644
index 0000000..76ba214
--- /dev/null
+++ b/tests/sigsuspend-zsh_tst.c
@@ -0,0 +1,46 @@
+/*
+ * Based on zsh's sigsuspend() configure test. Idea here is:
+ * - set a handler for SIGCHLD
+ * - fork a child
+ * - have parent do sigsuspend() and wait for SIGCHLD
+ * - have child exit notifying the parent
+ *
+ * If sandbox is mucking with SIGCHLD generation, this will often hang. #289963
+ */
+
+#include "tests.h"
+
+static int child;
+
+void handler(int sig) { child = sig; }
+
+int main()
+{
+ struct sigaction act;
+ sigset_t set;
+
+ /* Register the SIGCHLD handler */
+ act.sa_handler = &handler;
+ sigfillset(&act.sa_mask);
+ act.sa_flags = 0;
+ sigaction(SIGCHLD, &act, 0);
+
+ /* Mask all signals */
+ sigfillset(&set);
+ sigprocmask(SIG_SETMASK, &set, 0);
+
+ /* Fork the child */
+ pid_t pid = fork();
+ if (pid == -1)
+ abort();
+
+ if (pid == 0) {
+ /* Have child just exit to automatically send up SIGCHLD */
+ return 0;
+ } else {
+ /* Have parent enable all signals and wait for SIGCHLD */
+ sigemptyset(&set);
+ sigsuspend(&set);
+ return child == SIGCHLD ? 0 : 1;
+ }
+}