Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retry Apple & Cygwin unmount #503

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 18 additions & 6 deletions encfs/FileUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1737,15 +1737,27 @@ void unmountFS(const char *mountPoint) {
fuse_unmount(mountPoint, nullptr);
#ifdef __APPLE__
// fuse_unmount does not work on Mac OS, see #428
unmount(mountPoint, MNT_FORCE);
int ret = 3;
while (ret-- > 0) {
if (unmount(mountPoint, MNT_FORCE) == 0) {
break;
}
}
#endif
#ifdef __CYGWIN__
if(fork() == 0)
{
execl("/usr/bin/pkill", "/usr/bin/pkill", "-f", string("(^|/)encfs .*/.* ").append(mountPoint).append("?( |$)").c_str(), (char *)0);
}
int ret = 3;
pid_t pid;
int status;
wait(&status);
while (ret-- > 0) {
if ((pid = fork()) == 0) {
execl("/usr/bin/pkill", "/usr/bin/pkill", "-INT", "-f", string("(^|/)encfs .*/.* ").append(mountPoint).append("?( |$)").c_str(), (char *)0);
_Exit(127);
}
// pkill returns 1 if no process has been found
if ((pid > 0) && (waitpid(pid, &status, 0) > 0) && WIFEXITED(status) && (WEXITSTATUS(status) == 1)) {
break;
}
}
#endif
}

Expand Down