From: Dmitry V. Levin Date: Tue, 24 May 2016 11:10:22 +0000 (+0000) Subject: tests/attach-f-p.c: sleep a bit more to let the tracer catch up X-Git-Tag: v4.12~102 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9b49af1871174394b2f77fb53c5e92b38b5fce18;p=strace tests/attach-f-p.c: sleep a bit more to let the tracer catch up 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. --- diff --git a/tests/attach-f-p.c b/tests/attach-f-p.c index c0d4960e..2184990b 100644 --- a/tests/attach-f-p.c +++ b/tests/attach-f-p.c @@ -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);