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

This commit is contained in:
Mariusz Zaborski 2019-04-06 11:24:43 +00:00
parent a489026566
commit 8a9e93bb21
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=345984

View File

@ -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)