svn commit: r345984 - head/lib/libutil

Mariusz Zaborski oshogbo at FreeBSD.org
Sat Apr 6 11:24:44 UTC 2019


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)


More information about the svn-src-all mailing list