aboutsummaryrefslogtreecommitdiff
path: root/none
diff options
context:
space:
mode:
authorflorian <florian@a5019735-40e9-0310-863c-91ae7b9d1cf9>2015-07-31 06:58:16 +0000
committerflorian <florian@a5019735-40e9-0310-863c-91ae7b9d1cf9>2015-07-31 06:58:16 +0000
commitcb301491010188bbc3e1c064d3e58ceb5c9ab1e6 (patch)
treec8516ece9076a0d58528a429e3a1626c43d981f8 /none
parente37f83563585f5a0388c52de236184fe6e1604ff (diff)
downloadvalgrind-cb301491010188bbc3e1c064d3e58ceb5c9ab1e6.tar.gz
Fix testcase such that it can be run under cron on Solaris.
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 a5019735-40e9-0310-863c-91ae7b9d1cf9
Diffstat (limited to 'none')
-rw-r--r--none/tests/async-sigs.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/none/tests/async-sigs.c b/none/tests/async-sigs.c
index d027b6c3a..f05eb6e4e 100644
--- a/none/tests/async-sigs.c
+++ b/none/tests/async-sigs.c
@@ -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);