summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2005-07-11 05:32:56 (GMT)
committerH. Peter Anvin <hpa@zytor.com>2005-07-11 05:32:56 (GMT)
commit92086f9d40f3e71c5b829b350f56a920755b7fe6 (patch)
tree9db70a4183e404b827fa35b6ec5589c79e686822
parentad89d3d5f548f4ab31c047d2d0629b4df7f02610 (diff)
downloadflock-92086f9d40f3e71c5b829b350f56a920755b7fe6.zip
flock-92086f9d40f3e71c5b829b350f56a920755b7fe6.tar.gz
flock-92086f9d40f3e71c5b829b350f56a920755b7fe6.tar.bz2
flock-92086f9d40f3e71c5b829b350f56a920755b7fe6.tar.xz
Clean up some of the help stuff
-rw-r--r--flock.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/flock.c b/flock.c
index 3432f1e..fe325b0 100644
--- a/flock.c
+++ b/flock.c
@@ -1,4 +1,4 @@
-#ident "$Id$"
+/* $Id$ */
/* ----------------------------------------------------------------------- *
*
* Copyright 2003-2005 H. Peter Anvin - All Rights Reserved
@@ -141,6 +141,7 @@ int main(int argc, char *argv[])
memset(&timeout, 0, sizeof timeout);
+ optopt = 0;
while ( (opt = getopt_long(argc, argv, "+sexnouw:hV?", long_options, &ix)) != EOF ) {
switch(opt) {
case 's':
@@ -166,10 +167,11 @@ int main(int argc, char *argv[])
usage(EX_USAGE);
break;
case 'V':
- fprintf(stderr, "flock " VERSION "\n");
+ printf("flock " VERSION "\n");
exit(0);
default:
- usage((optopt != 'h' && optopt != '?') ? EX_USAGE : 0);
+ /* optopt will be set if this was an unrecognized option, i.e. *not* 'h' or '?' */
+ usage(optopt ? EX_USAGE : 0);
break;
}
}
@@ -225,7 +227,8 @@ int main(int argc, char *argv[])
if ( have_timeout ) {
if ( timeout.it_value.tv_sec == 0 &&
timeout.it_value.tv_usec == 0 ) {
- /* -w 0 is equivalent to -n */
+ /* -w 0 is equivalent to -n; this has to be special-cased
+ because setting an itimer to zero means disabled! */
have_timeout = 0;
block = LOCK_NB;
@@ -246,7 +249,7 @@ int main(int argc, char *argv[])
exit(1);
case EINTR: /* Signal received */
if ( timeout_expired )
- return 1; /* -w option set and failed to lock */
+ exit(1); /* -w option set and failed to lock */
continue; /* otherwise try again */
default: /* Other errors */
if ( filename )