]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Fix testcase such that it can be run under cron on Solaris.
authorFlorian Krohm <florian@eich-krohm.de>
Fri, 31 Jul 2015 06:58:16 +0000 (06:58 +0000)
committerFlorian Krohm <florian@eich-krohm.de>
Fri, 31 Jul 2015 06:58:16 +0000 (06:58 +0000)
The tescase depends on SIGHUP to be delivered but cron on Solaris
ignored the signal. So it needs to be enabled in child processes
after fork.
Patch by Ivo Raisr <ivosh@ivosh.net>.  Fixes BZ #350809.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15462

NEWS
none/tests/async-sigs.c

diff --git a/NEWS b/NEWS
index 77a1612b5f027bc6e58b6c43bb87a6e6dab2f519..52988cc94b6009b68c50fde1e628b8a786369540 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -269,6 +269,7 @@ where XXXXXX is the bug number as listed below.
 349874  Fix typos in source code
 349828  memcpy intercepts memmove causing src/dst overlap error (ppc64 ld.so)
 349941  di_notify_mmap might create wrong start/size DebugInfoMapping
+350809  Fix none/tests/async-sigs for Solaris
 350811  Remove reference to --db-attach which has been removed.
 n-i-bz  Provide implementations of certain compiler builtins to support
         compilers who may not provide those
index d027b6c3a267eff21ce1ebedc903f1aff553251b..f05eb6e4ebda2c2dee867950a424732c63e72f73 100644 (file)
@@ -22,6 +22,15 @@ static void handler(int sig)
 {
 }
 
+static void install_handler(int sig, void (*sig_handler)(int))
+{
+   struct sigaction sa;
+   sa.sa_handler = sig_handler;
+   sigemptyset(&sa.sa_mask);
+   sa.sa_flags = 0;
+   sigaction(sig, &sa, 0);
+}
+
 /* Kill our child, but use a separate kill command.  This is so that
    it's running independently of Valgrind, and so is async with
    respect to thread scheduling. */
@@ -87,11 +96,7 @@ static void test(int block, int caughtsig, int fatalsig)
    // - otherwise, wait in client code (by spinning).
    // The alarm() calls is so that if something breaks, we don't get stuck.
    if (pid == 0) {
-      struct sigaction sa;
-      sa.sa_handler = handler;
-      sigemptyset(&sa.sa_mask);
-      sa.sa_flags = 0;
-      sigaction(caughtsig, &sa, 0);
+      install_handler(caughtsig, handler);
       alarm(10);
 
       for (;;)
@@ -130,6 +135,9 @@ static void test(int block, int caughtsig, int fatalsig)
 
 int main()
 {
+   /* Restore default behaviour of SIGHUP when forked from cron. */
+   install_handler(SIGHUP, SIG_DFL);
+
    test(/*non-blocked*/0, /* sync*/SIGSEGV, /* sync*/SIGBUS);
    test(/*non-blocked*/0, /* sync*/SIGSEGV, /*async*/SIGHUP);
    test(/*non-blocked*/0, /*async*/SIGUSR1, /* sync*/SIGBUS);