aboutsummaryrefslogtreecommitdiff
path: root/sshfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'sshfs.c')
-rw-r--r--sshfs.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/sshfs.c b/sshfs.c
index d5cc0e7..61f2b92 100644
--- a/sshfs.c
+++ b/sshfs.c
@@ -11,6 +11,7 @@
#include <fuse.h>
#include <fuse_opt.h>
+#include <fuse_lowlevel.h>
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
@@ -3341,6 +3342,10 @@ int main(int argc, char *argv[])
if (!ch)
exit(1);
+ res = fcntl(fuse_chan_fd(ch), F_SETFD, FD_CLOEXEC);
+ if (res == -1)
+ perror("WARNING: failed to set FD_CLOESEC on fuse device");
+
fuse = fuse_new(ch, &args, cache_init(&sshfs_oper),
sizeof(struct fuse_operations), NULL);
if (fuse == NULL) {
@@ -3348,19 +3353,20 @@ int main(int argc, char *argv[])
exit(1);
}
- res = fuse_daemonize(foreground);
- if (res != -1)
- res = fuse_set_signal_handlers(fuse_get_session(fuse));
-
+ res = ssh_connect();
if (res == -1) {
fuse_unmount(mountpoint, ch);
fuse_destroy(fuse);
exit(1);
}
- res = ssh_connect();
+ res = fuse_daemonize(foreground);
+ if (res != -1)
+ res = fuse_set_signal_handlers(fuse_get_session(fuse));
+
if (res == -1) {
- fuse_teardown(fuse, mountpoint);
+ fuse_unmount(mountpoint, ch);
+ fuse_destroy(fuse);
exit(1);
}