aboutsummaryrefslogtreecommitdiff
path: root/mount.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2017-01-02 23:29:52 +0100
committerJakob Unterwurzacher2017-01-02 23:29:52 +0100
commit53aedc378345f7dba5cdd0544b4aa60733505623 (patch)
tree5ac3241b3323610adecd648da347829cd63a8bf4 /mount.go
parent9be3d2c214b38db8cc1674c64d2b7fbfaad376bf (diff)
main: disconnect from the controlling terminal
This prevents us from getting SIGINT when the user kills the running script.
Diffstat (limited to 'mount.go')
-rw-r--r--mount.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/mount.go b/mount.go
index bd65fc6..3e93169 100644
--- a/mount.go
+++ b/mount.go
@@ -96,9 +96,9 @@ func doMount(args *argContainer) int {
// Initialize FUSE server
srv := initFuseFrontend(masterkey, args, confFile)
tlog.Info.Println(tlog.ColorGreen + "Filesystem mounted and ready." + tlog.ColorReset)
+ var paniclog *os.File
// We have been forked into the background, as evidenced by the set
// "notifypid".
- var paniclog *os.File
if args.notifypid > 0 {
// Chdir to the root directory so we don't block unmounting the CWD
os.Chdir("/")
@@ -124,6 +124,13 @@ func doMount(args *argContainer) int {
syscall.Dup2(int(paniclog.Fd()), 1)
syscall.Dup2(int(paniclog.Fd()), 2)
}
+ // Disconnect from the controlling terminal by creating a new session.
+ // This prevents us from getting SIGINT when the user presses Ctrl-C
+ // to exit a running script that has called gocryptfs.
+ _, err = syscall.Setsid()
+ if err != nil {
+ tlog.Warn.Printf("Setsid: %v", err)
+ }
// Send SIGUSR1 to our parent
sendUsr1(args.notifypid)
}