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)
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to