This is the mail archive of the glibc-cvs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GNU C Library master sources branch roland/tst-waitid created. glibc-2.17-797-g753d41d


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, roland/tst-waitid has been created
        at  753d41d45522dae3e0e0d640cc2cfb485a561ba4 (commit)

- Log -----------------------------------------------------------------
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=753d41d45522dae3e0e0d640cc2cfb485a561ba4

commit 753d41d45522dae3e0e0d640cc2cfb485a561ba4
Author: Roland McGrath <roland@hack.frob.com>
Date:   Wed Jun 12 17:01:59 2013 -0700

    Fix raciness in waitid test.

diff --git a/ChangeLog b/ChangeLog
index d08f0a6..758ddea 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2013-06-12  Roland McGrath  <roland@hack.frob.com>
+
+	* posix/tst-waitid.c (do_test): Distinguish different instances of
+	stopped/continued in CHECK_SIGCHLD uses.  Insert a delay between
+	sending SIGSTOP and calling waitpid to ensure SIGCHLD gets delivered
+	before entering the kernel for waitpid.
+
 2013-06-11  Adhemerval Zanella  <azanella@linux.vnet.ibm.com>
 
 	[BZ #15605]
diff --git a/posix/tst-waitid.c b/posix/tst-waitid.c
index ad3df5a..57a6a3f 100644
--- a/posix/tst-waitid.c
+++ b/posix/tst-waitid.c
@@ -145,7 +145,7 @@ do_test (int argc, char *argv[])
   /* Give the child a chance to stop.  */
   sleep (3);
 
-  CHECK_SIGCHLD ("stopped", CLD_STOPPED, SIGSTOP);
+  CHECK_SIGCHLD ("stopped (before waitid)", CLD_STOPPED, SIGSTOP);
 
   /* Now try a wait that should not succeed.  */
   siginfo_t info;
@@ -227,7 +227,7 @@ do_test (int argc, char *argv[])
       expecting_sigchld = 0;
     }
   else
-    CHECK_SIGCHLD ("continued", CLD_CONTINUED, SIGCONT);
+    CHECK_SIGCHLD ("continued (before waitid)", CLD_CONTINUED, SIGCONT);
 
   info.si_signo = 0;		/* A successful call sets it to SIGCHLD.  */
   info.si_pid = -1;
@@ -336,6 +336,13 @@ do_test (int argc, char *argv[])
       printf ("kill (%d, SIGSTOP): %m\n", pid);
       RETURN (EXIT_FAILURE);
     }
+
+  /* Give the child a chance to stop.  The waitpid call below will block
+     until it has stopped, but if we are real quick and enter the waitpid
+     system call before the SIGCHLD has been generated, then it will be
+     discarded and never delivered.  */
+  sleep (3);
+
   pid_t wpid = waitpid (pid, &fail, WUNTRACED);
   if (wpid < 0)
     {
@@ -354,7 +361,7 @@ do_test (int argc, char *argv[])
       printf ("waitpid WUNTRACED on stopped: status %x\n", fail);
       RETURN (EXIT_FAILURE);
     }
-  CHECK_SIGCHLD ("stopped", CLD_STOPPED, SIGSTOP);
+  CHECK_SIGCHLD ("stopped (after waitpid)", CLD_STOPPED, SIGSTOP);
 
   expecting_sigchld = 1;
   if (kill (pid, SIGCONT) != 0)
@@ -372,7 +379,7 @@ do_test (int argc, char *argv[])
       expecting_sigchld = 0;
     }
   else
-    CHECK_SIGCHLD ("continued", CLD_CONTINUED, SIGCONT);
+    CHECK_SIGCHLD ("continued (before waitpid)", CLD_CONTINUED, SIGCONT);
 
   wpid = waitpid (pid, &fail, WCONTINUED);
   if (wpid < 0)

-----------------------------------------------------------------------


hooks/post-receive
-- 
GNU C Library master sources


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]