summaryrefslogtreecommitdiffstats
path: root/lib/libutil/pidfile.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libutil/pidfile.c')
-rw-r--r--lib/libutil/pidfile.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/lib/libutil/pidfile.c b/lib/libutil/pidfile.c
index c572551..983d103 100644
--- a/lib/libutil/pidfile.c
+++ b/lib/libutil/pidfile.c
@@ -31,13 +31,13 @@ __FBSDID("$FreeBSD$");
#include <sys/file.h>
#include <sys/stat.h>
-#include <errno.h>
-#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
+#include <fcntl.h>
#include <string.h>
-
+#include <err.h>
+#include <errno.h>
#include <libutil.h>
static int _pidfile_remove(struct pidfh *pfh, int freeit);
@@ -207,14 +207,8 @@ pidfile_close(struct pidfh *pfh)
static int
_pidfile_remove(struct pidfh *pfh, int freeit)
{
- struct flock lock;
int error;
- lock.l_type = F_UNLCK;
- lock.l_start = 0;
- lock.l_whence = SEEK_SET;
- lock.l_len = 0;
-
error = pidfile_verify(pfh);
if (error != 0) {
errno = error;
@@ -223,7 +217,7 @@ _pidfile_remove(struct pidfh *pfh, int freeit)
if (unlink(pfh->pf_path) == -1)
error = errno;
- if (fcntl(pfh->pf_fd, F_SETLK, &lock) == -1) {
+ if (flock(pfh->pf_fd, LOCK_UN) == -1) {
if (error == 0)
error = errno;
}
OpenPOWER on IntegriCloud