9 #define TEST(c, ...) ((c) ? 1 : (t_error(#c" failed: " __VA_ARGS__),0))
10 #define TESTE(c) (errno=0, TEST(c, "errno = %s\n", strerror(errno)))
14 struct flock fl
= {0};
20 if (!TESTE(f
=tmpfile())) return t_status
;
24 fl
.l_whence
= SEEK_SET
;
27 TESTE(fcntl(fd
, F_SETLK
, &fl
)==0);
32 _exit(fcntl(fd
, F_SETLK
, &fl
)==0 ||
33 (errno
!=EAGAIN
&& errno
!=EACCES
));
35 while (waitpid(pid
, &status
, 0)<0 && errno
==EINTR
);
36 TEST(status
==0, "lock failed to work\n");
41 _exit(fcntl(fd
, F_GETLK
, &fl
) || fl
.l_pid
!= getppid());
43 while (waitpid(pid
, &status
, 0)<0 && errno
==EINTR
);
44 TEST(status
==0, "child failed to detect lock held by parent\n");