I found that on SLES10 PPC that the stack_grow_into_huge test would not
stop the child process, even with the barrier hack. The below patch
changes the test so that if the child doesn't die within 5 seconds, we
kill it and fail the test. It still returns immediately if the child is
terminated as expected with a proper kernel.

Signed-off-by: Steve Fox <[EMAIL PROTECTED]>

diff --git a/tests/stack_grow_into_huge.c b/tests/stack_grow_into_huge.c
index 33232bf..7d59ff5 100644
--- a/tests/stack_grow_into_huge.c
+++ b/tests/stack_grow_into_huge.c
@@ -22,6 +22,9 @@
 #include <stdio.h>
 #include <string.h>
 #include <unistd.h>
+#include <signal.h>
+#include <time.h>
+#include <errno.h>
 #include <sys/mman.h>
 #include <sys/resource.h>
 #include <sys/wait.h>
@@ -56,7 +59,9 @@ void do_child()
 
 int main(int argc, char *argv[])
 {
-       int fd, pid, s, ret;
+       int fd, s, ret;
+       pid_t pid;
+       time_t stop;
        struct rlimit r;
        char *b;
        unsigned long hpage_size = gethugepagesize();
@@ -88,10 +93,6 @@ int main(int argc, char *argv[])
                exit(0);
        }
 
-       ret = waitpid(pid, &s, 0);
-       if (ret == -1)
-               FAIL("waitpid");
-
        /*
         * The child grows its stack until a failure occurs.  We expect
         * this to result in a SIGSEGV.  If any other signal is
@@ -99,14 +100,20 @@ int main(int argc, char *argv[])
         * determine the kernel has not behaved correctly and trigger a
         * test failure.
         */
-       if (WIFSIGNALED(s)) {
-               int sig = WTERMSIG(s);
-
-               if (sig == SIGSEGV) {
-                       PASS();
-               } else {
-                       FAIL("Got unexpected signal: %s", strsignal(sig));
+       stop = time(NULL) + 5;
+       while(time(NULL) < stop) {
+               ret = waitpid(pid, &s, WNOHANG);
+               if (ret == -1)
+                       FAIL("waitpid");
+               if (WIFSIGNALED(s)) {
+                       int sig = WTERMSIG(s);
+                       if (sig == SIGSEGV) {
+                               PASS();
+                       }
                }
        }
+       ret = kill(pid, SIGKILL);
+       if (ret == -1)
+               printf("Could not kill child process: %s\n", strerror(errno));
        FAIL("Child not signalled");
 }


-- 

Steve Fox
IBM Linux Technology Center


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Libhugetlbfs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel

Reply via email to