Page MenuHomeFreeBSD

D42711.id130588.diff
No OneTemporary

D42711.id130588.diff

diff --git a/usr.bin/lockf/lockf.c b/usr.bin/lockf/lockf.c
--- a/usr.bin/lockf/lockf.c
+++ b/usr.bin/lockf/lockf.c
@@ -38,7 +38,7 @@
#include <sysexits.h>
#include <unistd.h>
-static int acquire_lock(const char *name, int flags);
+static int acquire_lock(const char *name, int flags, int silent);
static void cleanup(void);
static void killed(int sig);
static void timeout(int sig);
@@ -125,13 +125,14 @@
* avoiding the separate step of waiting for the lock. This
* yields fairness and improved performance.
*/
- lockfd = acquire_lock(lockname, flags | O_NONBLOCK);
+ lockfd = acquire_lock(lockname, flags | O_NONBLOCK, silent);
while (lockfd == -1 && !timed_out && waitsec != 0) {
if (keep)
- lockfd = acquire_lock(lockname, flags);
+ lockfd = acquire_lock(lockname, flags, silent);
else {
wait_for_lock(lockname);
- lockfd = acquire_lock(lockname, flags | O_NONBLOCK);
+ lockfd = acquire_lock(lockname, flags | O_NONBLOCK,
+ silent);
}
}
if (waitsec > 0)
@@ -168,15 +169,18 @@
* on success, or -1 on failure.
*/
static int
-acquire_lock(const char *name, int flags)
+acquire_lock(const char *name, int flags, int silent)
{
int fd;
if ((fd = open(name, O_EXLOCK|flags, 0666)) == -1) {
if (errno == EAGAIN || errno == EINTR)
return (-1);
- else if (errno == ENOENT && (flags & O_CREAT) == 0)
- err(EX_UNAVAILABLE, "%s", name);
+ else if (errno == ENOENT && (flags & O_CREAT) == 0) {
+ if (!silent)
+ warn("%s", name);
+ exit(EX_UNAVAILABLE);
+ }
err(EX_CANTCREAT, "cannot open %s", name);
}
return (fd);

File Metadata

Mime Type
text/plain
Expires
Mon, Jul 20, 3:29 AM (3 h, 12 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
35264226
Default Alt Text
D42711.id130588.diff (1 KB)

Event Timeline