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.
This commit is contained in:
Дмитрий Левин 2016-05-24 11:10:22 +00:00
parent 475d2b5da6
commit 9b49af1871

View 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);