|
Lines 1-4
Link Here
|
| 1 |
/* $Id: dpid.c 125 2007-06-22 15:09:47Z lennart $ */ |
1 |
/* $Id: dpid.c 131 2007-09-10 16:52:17Z lennart $ */ |
| 2 |
|
2 |
|
| 3 |
/* |
3 |
/* |
| 4 |
* This file is part of libdaemon. |
4 |
* This file is part of libdaemon. |
|
Lines 69-74
Link Here
|
| 69 |
f.l_len = 0; |
69 |
f.l_len = 0; |
| 70 |
|
70 |
|
| 71 |
if (fcntl(fd, F_SETLKW, &f) < 0) { |
71 |
if (fcntl(fd, F_SETLKW, &f) < 0) { |
|
|
72 |
|
| 73 |
if (enable && errno == EBADF) { |
| 74 |
f.l_type = F_RDLCK; |
| 75 |
|
| 76 |
if (fcntl(fd, F_SETLKW, &f) >= 0) |
| 77 |
return 0; |
| 78 |
} |
| 79 |
|
| 72 |
daemon_log(LOG_WARNING, "fcntl(F_SETLKW) failed: %s", strerror(errno)); |
80 |
daemon_log(LOG_WARNING, "fcntl(F_SETLKW) failed: %s", strerror(errno)); |
| 73 |
return -1; |
81 |
return -1; |
| 74 |
} |
82 |
} |
|
Lines 91-100
Link Here
|
| 91 |
} |
99 |
} |
| 92 |
|
100 |
|
| 93 |
if ((fd = open(fn, O_RDWR, 0644)) < 0) { |
101 |
if ((fd = open(fn, O_RDWR, 0644)) < 0) { |
| 94 |
if (errno != ENOENT) |
102 |
if ((fd = open(fn, O_RDONLY, 0644)) < 0) { |
| 95 |
daemon_log(LOG_WARNING, "Failed to open PID file: %s", strerror(errno)); |
103 |
if (errno != ENOENT) |
|
|
104 |
daemon_log(LOG_WARNING, "Failed to open PID file: %s", strerror(errno)); |
| 96 |
|
105 |
|
| 97 |
goto finish; |
106 |
goto finish; |
|
|
107 |
} |
| 98 |
} |
108 |
} |
| 99 |
|
109 |
|
| 100 |
if ((locked = lock_file(fd, 1)) < 0) |
110 |
if ((locked = lock_file(fd, 1)) < 0) |