]> granicus.if.org Git - strace/commitdiff
tests/attach-f-p.c: sleep a bit more to let the tracer catch up
authorDmitry V. Levin <ldv@altlinux.org>
Tue, 24 May 2016 11:10:22 +0000 (11:10 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Tue, 24 May 2016 12:14:33 +0000 (12:14 +0000)
On noticeably lagging systems, the parent process may invoke its chdir
call before the tracer gets notified about completion of its last child
process.  Add extra sleep in the parent process to win the race.

* tests/attach-f-p.c (main): Change timerid into a static array.
Arm a timer in the parent process and wait for it.

tests/attach-f-p.c

index c0d4960ec869148af14ee70f539c6f54e6a6e3c4..2184990b45cad050afa13e1f9dbd582167183877 100644 (file)
@@ -84,6 +84,7 @@ thread(void *a)
 int
 main(void)
 {
+       static timer_t timerid[N];
        pthread_t t[N];
        unsigned int i;
 
@@ -101,11 +102,10 @@ main(void)
                        .sigev_notify = SIGEV_SIGNAL,
                        .sigev_signo = sigs[i]
                };
-               timer_t timerid;
-               if (timer_create(CLOCK_MONOTONIC, &sev, &timerid))
+               if (timer_create(CLOCK_MONOTONIC, &sev, &timerid[i]))
                        perror_msg_and_skip("timer_create");
 
-               if (timer_settime(timerid, 0, &its[i], NULL))
+               if (timer_settime(timerid[i], 0, &its[i], NULL))
                        perror_msg_and_fail("timer_settime");
 
                errno = pthread_create(&t[i], NULL, thread, (void *) &args[i]);
@@ -127,6 +127,14 @@ main(void)
                       retval.pid, child[i], retval.pid);
        }
 
+       /* sleep a bit more to late the tracer catch up */
+       if (timer_settime(timerid[0], 0, &its[0], NULL))
+               perror_msg_and_fail("timer_settime");
+       int signo;
+       errno = sigwait(&args[0].set, &signo);
+       if (errno)
+               perror_msg_and_fail("sigwait");
+
        pid_t pid = getpid();
        assert(chdir(text_parent) == -1);