* SUCH DAMAGE.
*/
+#include <sys/file.h>
+
#include <errno.h>
#include <fcntl.h>
#include <inttypes.h>
#include <unistd.h>
#include "pidfile.h"
-#include "../defs.h"
+#include "../config.h"
static pid_t pidfile_pid;
static char *pidfile_path;
pidfile_fd = -1;
/* Don't unlink, other process has lock. */
errno = error;
- return -1;
+ return errno == EAGAIN ? pidfile_read(path) : -1;
}
#endif
#ifndef O_CLOEXEC
if (!(ctx.options & DHCPCD_TEST)) {
if ((pid = pidfile_lock(ctx.pidfile)) != 0) {
- logger(&ctx, LOG_ERR, ""PACKAGE
- " already running on pid %d (%s)",
- pid, ctx.pidfile);
+ if (pid == -1)
+ logger(&ctx, LOG_ERR, "%s: pidfile_lock: %m",
+ __func__);
+ else
+ logger(&ctx, LOG_ERR, ""PACKAGE
+ " already running on pid %d (%s)",
+ pid, ctx.pidfile);
goto exit_failure;
}