]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Add small sleep to none/tests/pth_2sig to help prevent hanging
authorPaul Floyd <pjfloyd@wanadoo.fr>
Mon, 23 May 2022 19:27:58 +0000 (21:27 +0200)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Mon, 23 May 2022 19:27:58 +0000 (21:27 +0200)
On FreeBSD 13.0 x86 this testcase was hanging on some systems.
It seems like the SIGTERM signals were not being recieved
before the child exited, which left the parent hanging in the
pause() waiting to be killed.

Reported, patch provided and tested by Nick Briggs.

none/tests/pth_2sig.c

index 56e6904c0139a4bcb616e4e977fdaf04538d6086..31cd710ce993651304742f7be129127ae9d8e26f 100644 (file)
@@ -14,6 +14,7 @@ void *slavethread(void *arg)
 
 int main(int argc, char **argv)
 {
+    const struct timespec alittle = { 0, 1000000000 / 100 };   // 0.01 seconds.
     int i;
     for (i = 0; i < 10; i++) {
         pthread_t slave;
@@ -28,7 +29,7 @@ int main(int argc, char **argv)
         case 0: // child
             sleep(2); // Should be enough to ensure (some) threads are created
             for (i = 0; i < 20 && kill(pid, SIGTERM) == 0; i++)
-                ;
+                nanosleep(&alittle, NULL);
             exit(0);
         case -1:
             perror("fork");