aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/mount.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/mount.c b/lib/mount.c
index a1875f0..5c568e9 100644
--- a/lib/mount.c
+++ b/lib/mount.c
@@ -16,6 +16,7 @@
#include <stddef.h>
#include <fcntl.h>
#include <errno.h>
+#include <sys/poll.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <sys/wait.h>
@@ -174,13 +175,21 @@ void fuse_unmount_compat22(const char *mountpoint)
void fuse_unmount(const char *mountpoint, int fd)
{
const char *mountprog = FUSERMOUNT_PROG;
+ struct pollfd pfd;
+ int res;
int pid;
- (void) fd;
-
if (!mountpoint)
return;
+ pfd.fd = fd;
+ pfd.events = 0;
+ res = poll(&pfd, 1, 0);
+ /* If file poll returns POLLERR on the device file descriptor,
+ then the filesystem is already unmounted */
+ if (res == 1 && (pfd.revents & POLLERR))
+ return;
+
#ifdef HAVE_FORK
pid = fork();
#else