*
* This is free software, licensed under the GNU General Public License v2.
*/
+
+//usage:#define flock_trivial_usage
+//usage: "[-sxun] FD|{FILE [-c] PROG ARGS}"
+//usage:#define flock_full_usage "\n\n"
+//usage: "[Un]lock file descriptor, or lock FILE, run PROG\n"
+//usage: "\n -s Shared lock"
+//usage: "\n -x Exclusive lock (default)"
+//usage: "\n -u Unlock FD"
+//usage: "\n -n Fail rather than wait"
+
#include <sys/file.h>
#include "libbb.h"
};
#if ENABLE_LONG_OPTS
- static const char getopt_longopts[] ALIGN1 =
+ static const char getopt_longopts[] ALIGN1 =
"shared\0" No_argument "s"
"exclusive\0" No_argument "x"
"unlock\0" No_argument "u"
if (argv[1]) {
fd = open(argv[0], O_RDONLY|O_NOCTTY|O_CREAT, 0666);
if (fd < 0 && errno == EISDIR)
- fd = open(argv[0], O_RDONLY|O_NOCTTY);
+ fd = open(argv[0], O_RDONLY|O_NOCTTY);
if (fd < 0)
bb_perror_msg_and_die("can't open '%s'", argv[0]);
//TODO? close_on_exec_on(fd);
} else {
- fd = xatoi_u(argv[0]);
+ fd = xatoi_positive(argv[0]);
}
argv++;