diff options
author | Miklos Szeredi <miklos@szeredi.hu> | 2010-04-28 08:59:12 +0000 |
---|---|---|
committer | Miklos Szeredi <miklos@szeredi.hu> | 2010-04-28 08:59:12 +0000 |
commit | b1b0c4b6f58d278360243705cc1e67522ef23423 (patch) | |
tree | dc0d5243d102021a80018837dccdced49c65e422 /sshfs.c | |
parent | f018ac3b1cf51ec3bf5d47f89f9dab3809cd2709 (diff) | |
download | sshfs-b1b0c4b6f58d278360243705cc1e67522ef23423.tar sshfs-b1b0c4b6f58d278360243705cc1e67522ef23423.tar.gz sshfs-b1b0c4b6f58d278360243705cc1e67522ef23423.tar.bz2 sshfs-b1b0c4b6f58d278360243705cc1e67522ef23423.zip |
* Set FD_CLOEXEC on fuse device. This prevents deadlocks that
happen in some circumstances (bugzilla.kernel.org #12864).
Diffstat (limited to 'sshfs.c')
-rw-r--r-- | sshfs.c | 18 |
1 files changed, 12 insertions, 6 deletions
@@ -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); } |