From: Roy Marples Date: Mon, 18 Apr 2016 08:34:56 +0000 (+0000) Subject: Sync latest from NetBSD. X-Git-Tag: v6.10.3~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a4cc58fc3f1a8bc478f2ef75f5bc75b1b850c274;p=thirdparty%2Fdhcpcd.git Sync latest from NetBSD. --- diff --git a/compat/pidfile.c b/compat/pidfile.c index b301a574..129c8d1d 100644 --- a/compat/pidfile.c +++ b/compat/pidfile.c @@ -1,4 +1,4 @@ -/* $NetBSD: pidfile.c,v 1.12 2016/04/10 19:05:50 roy Exp $ */ +/* $NetBSD: pidfile.c,v 1.14 2016/04/12 20:40:43 roy Exp $ */ /*- * Copyright (c) 1999, 2016 The NetBSD Foundation, Inc. @@ -31,10 +31,9 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: pidfile.c,v 1.11 2015/01/22 19:04:28 christos Exp $"); +__RCSID("$NetBSD: pidfile.c,v 1.14 2016/04/12 20:40:43 roy Exp $"); #endif -#include #include #include @@ -142,13 +141,12 @@ pidfile_read(const char *path) ssize_t n; pid_t pid; - if (path == NULL) { - if (pidfile_path[0] != '\0') - path = pidfile_path; - else if (pidfile_varrun_path(dpath, sizeof(dpath), NULL) == -1) + if (path == NULL && pidfile_path[0] != '\0') + path = pidfile_path; + if (path == NULL || strchr(path, '/') == NULL) { + if (pidfile_varrun_path(dpath, sizeof(dpath), path) == -1) return -1; - else - path = dpath; + path = dpath; } if ((fd = open(path, O_RDONLY | O_NONBLOCK)) == -1) @@ -190,14 +188,14 @@ pidfile_lock(const char *path) } if (path == NULL || strchr(path, '/') == NULL) { - if (pidfile_varrun_path(dpath, sizeof(dpath), NULL) == -1) + if (pidfile_varrun_path(dpath, sizeof(dpath), path) == -1) return -1; path = dpath; } /* If path has changed (no good reason), clean up the old pidfile. */ - if (strcmp(pidfile_path, path) != 0) - pidfile_cleanup(); + if (pidfile_fd != -1 && strcmp(pidfile_path, path) != 0) + pidfile_clean(); if (pidfile_fd == -1) { int fd, opts;