Skip to content

Commit

Permalink
tests/attach-f-p.c: fix race condition
Browse files Browse the repository at this point in the history
* tests/attach-f-p.c (thread): Allow read() to fail with EINTR.
  • Loading branch information
ldv-alt committed Nov 29, 2021
1 parent bb1ca49 commit 17bf9d9
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions tests/attach-f-p.c
Expand Up @@ -38,10 +38,13 @@ static void *
thread(void *a)
{
unsigned int no = (long) a;
int i;
int i, rc;

if (read(pipes[no][0], &i, sizeof(i)) != (int) sizeof(i))
while ((rc = read(pipes[no][0], &i, sizeof(i))) != (int) sizeof(i)) {
if (rc < 0 && errno == EINTR)
continue;
perror_msg_and_fail("read[%u]", no);
}
assert(chdir(child[no]) == -1);
retval_t retval = { .pid = syscall(__NR_gettid) };
return retval.ptr;
Expand Down

0 comments on commit 17bf9d9

Please sign in to comment.