libdaemon/bnc-309132.patch

41 lines
1.2 KiB
Diff

diff -Naur libdaemon-0.12/libdaemon/dpid.c /suse/mauro/libdaemon/libdaemon/dpid.c
--- libdaemon-0.12/libdaemon/dpid.c 2007-07-10 19:58:34.000000000 +0200
+++ /suse/mauro/libdaemon/libdaemon/dpid.c 2007-09-13 22:15:16.046491000 +0200
@@ -1,4 +1,4 @@
-/* $Id: dpid.c 125 2007-06-22 15:09:47Z lennart $ */
+/* $Id: dpid.c 131 2007-09-10 16:52:17Z lennart $ */
/*
* This file is part of libdaemon.
@@ -69,6 +69,14 @@
f.l_len = 0;
if (fcntl(fd, F_SETLKW, &f) < 0) {
+
+ if (enable && errno == EBADF) {
+ f.l_type = F_RDLCK;
+
+ if (fcntl(fd, F_SETLKW, &f) >= 0)
+ return 0;
+ }
+
daemon_log(LOG_WARNING, "fcntl(F_SETLKW) failed: %s", strerror(errno));
return -1;
}
@@ -91,10 +99,12 @@
}
if ((fd = open(fn, O_RDWR, 0644)) < 0) {
- if (errno != ENOENT)
- daemon_log(LOG_WARNING, "Failed to open PID file: %s", strerror(errno));
+ if ((fd = open(fn, O_RDONLY, 0644)) < 0) {
+ if (errno != ENOENT)
+ daemon_log(LOG_WARNING, "Failed to open PID file: %s", strerror(errno));
- goto finish;
+ goto finish;
+ }
}
if ((locked = lock_file(fd, 1)) < 0)