break;
case 'V':
printf("flock (%s)\n", PACKAGE_STRING);
- exit(0);
+ exit(EX_OK);
default:
/* optopt will be set if this was an unrecognized
* option, i.e. *not* 'h' or '?
if (fd < 0) {
warn(_("cannot open lock file %s"), argv[optind]);
- exit((errno == ENOMEM || errno == EMFILE
- || errno == ENFILE) ? EX_OSERR : (errno == EROFS
- || errno ==
- ENOSPC) ?
- EX_CANTCREAT : EX_NOINPUT);
+ if (errno == ENOMEM || errno == EMFILE || errno == ENFILE)
+ exit(EX_OSERR);
+ if (errno == EROFS || errno == ENOSPC)
+ exit(EX_CANTCREAT);
+ exit(EX_NOINPUT);
}
} else if (optind < argc) {
/* Use provided file descriptor */
while (flock(fd, type | block)) {
switch (errno) {
case EWOULDBLOCK:
- /* -n option set and failed to lock */
+ /* -n option set and failed to lock. The numeric
+ * exit value is specified in man flock.1
+ */
exit(1);
case EINTR:
/* Signal received */
if (timeout_expired)
- /* -w option set and failed to lock */
+ /* -w option set and failed to lock. The
+ * numeric exit value is specified in man
+ * flock.1
+ */
exit(1);
/* otherwise try again */
continue;
sigaction(SIGALRM, &old_sa, NULL);
}
- status = 0;
+ status = EX_OK;
if (cmd_argv) {
pid_t w, f;