Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 6 Apr 2019 11:24:43 +0000 (UTC)
From:      Mariusz Zaborski <oshogbo@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r345984 - head/lib/libutil
Message-ID:  <201904061124.x36BOhbv001525@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: oshogbo
Date: Sat Apr  6 11:24:43 2019
New Revision: 345984
URL: https://svnweb.freebsd.org/changeset/base/345984

Log:
  Use funlinkat in pidfile to ensure we are removing the right file.

Modified:
  head/lib/libutil/pidfile.c

Modified: head/lib/libutil/pidfile.c
==============================================================================
--- head/lib/libutil/pidfile.c	Sat Apr  6 09:37:10 2019	(r345983)
+++ head/lib/libutil/pidfile.c	Sat Apr  6 11:24:43 2019	(r345984)
@@ -293,8 +293,11 @@ _pidfile_remove(struct pidfh *pfh, int freeit)
 		return (-1);
 	}
 
-	if (unlinkat(pfh->pf_dirfd, pfh->pf_filename, 0) == -1)
+	if (funlinkat(pfh->pf_dirfd, pfh->pf_filename, pfh->pf_fd, 0) == -1) {
+		if (errno == EDEADLK)
+			return (-1);
 		error = errno;
+	}
 	if (close(pfh->pf_fd) == -1 && error == 0)
 		error = errno;
 	if (close(pfh->pf_dirfd) == -1 && error == 0)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201904061124.x36BOhbv001525>