]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Merge r9380, r9381 (test portability tweaks) from the DARWIN branch.
authorNicholas Nethercote <njn@valgrind.org>
Fri, 13 Mar 2009 05:38:01 +0000 (05:38 +0000)
committerNicholas Nethercote <njn@valgrind.org>
Fri, 13 Mar 2009 05:38:01 +0000 (05:38 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9394

none/tests/coolo_sigaction.cpp
none/tests/coolo_sigaction.stdout.exp
none/tests/sigstackgrowth.c

index 7baa4aef4289ed46bf5533a02c25d427365947ce..2481746465f8dcdd630e0e384d756a5e5bb4cfcc 100644 (file)
@@ -8,7 +8,7 @@ static struct sigaction oldChildHandlerData;
 
 void theHandler(int arg)
 {
-  printf("handled %d\n", arg);
+  printf("handled %s\n", arg == SIGCHLD ? "SIGCHLD" : "?!unexpected signal?!" );
 }
 
 void setupHandlers()
index 652c76e2fa7bb4bd70887f2975dac5845c6f91ae..600b45fe45ae63129a17309720bc9de540e8f95a 100644 (file)
@@ -1 +1 @@
-handled 17
+handled SIGCHLD
index 3b40896bc0198cf8266289d3024475a047c279c6..3f687961cdf848b2349079e67c9666ab5539fb04 100644 (file)
@@ -4,9 +4,25 @@
 #include <sys/types.h>
 #include <unistd.h>
 
-#if defined(_AIX) && !defined(SA_NOMASK)
-# define SA_NOMASK 0
-#endif
+/* What does this test do?  It checks that valgrind's signal frame
+   building mechanism can create at least 4MB of signal delivery
+   frames, hence that it can actually expand the stack by that much
+   when delivering signals.  A fair-enough thing to want to test.
+
+   It does this by getting into the signal handler, and then
+   recursively invoking the handler by sending itself the signal
+   again, until the stack has grown to 4MB from the starting frame
+   (main).
+
+   Consequence is: it is essential that we do not disable delivery of
+   further signals within the handler itself, else the kernel will
+   wait till the handler exits before delivering the next signal, the
+   frame will be cleared, the stack will never grow, and we'll be in
+   an infinite loop.
+
+   Hence we *must* give the SA_NODEFER flag when setting up the
+   handler.
+*/
 
 static char *deep;
 
@@ -32,7 +48,7 @@ int main()
        deep = &here - SIZE;
 
        sa.sa_handler = handler;
-       sa.sa_flags = SA_NOMASK;
+       sa.sa_flags = SA_NODEFER;
        sigemptyset(&sa.sa_mask);
        
        sigaction(SIGUSR1, &sa, NULL);
@@ -42,3 +58,4 @@ int main()
        printf("FAILED\n");
        exit(1);
 }
+