diff --git a/lib/libshare/os/freebsd/nfs.c b/lib/libshare/os/freebsd/nfs.c index 0041bc228bb5..8abc3bf82303 100644 --- a/lib/libshare/os/freebsd/nfs.c +++ b/lib/libshare/os/freebsd/nfs.c @@ -306,9 +306,10 @@ nfs_commit_shares(void) struct pidfh *pfh; pid_t mountdpid; +start: pfh = pidfile_open(_PATH_MOUNTDPID, 0600, &mountdpid); if (pfh != NULL) { - /* Mountd is not running. */ + /* mountd(8) is not running. */ pidfile_remove(pfh); return (SA_OK); } @@ -316,6 +317,11 @@ nfs_commit_shares(void) /* Cannot open pidfile for some reason. */ return (SA_SYSTEM_ERR); } + if (mountdpid == -1) { + /* mountd(8) exists, but didn't write the PID yet */ + usleep(500); + goto start; + } /* We have mountd(8) PID in mountdpid variable. */ kill(mountdpid, SIGHUP); return (SA_OK);