sleep(2);
fd = open(DATA, O_RDONLY);
- if (fd == -1) exit(1);
+ if (fd == -1) {
+ fprintf(stderr,"ERROR: failed to open %s (errno=%d)\n",
+ DATA, (int)errno);
+ exit(1);
+ }
lock.l_type = F_WRLCK;
lock.l_whence = SEEK_SET;
if ((ret == -1) ||
(lock.l_type == F_UNLCK)) {
+ fprintf(stderr,"ERROR: lock test failed (ret=%d errno=%d)\n", ret, (int)errno);
exit(1);
} else {
exit(0);
fd = open(DATA, O_RDWR|O_CREAT|O_TRUNC, 0600);
+ if (fd == -1) {
+ fprintf(stderr,"ERROR: failed to open %s (errno=%d)\n",
+ DATA, (int)errno);
+ exit(1);
+ }
+
lock.l_type = F_WRLCK;
lock.l_whence = SEEK_SET;
lock.l_start = 0;
status = (status == 0) ? 0 : 1;
#endif /* defined(WIFEXITED) && defined(WEXITSTATUS) */
+ if (status) {
+ fprintf(stderr,"ERROR: lock test failed with status=%d\n",
+ status);
+ }
+
exit(status);
}