diff options
author | Jakob Unterwurzacher | 2015-10-06 00:29:08 +0200 |
---|---|---|
committer | Jakob Unterwurzacher | 2015-10-06 00:31:18 +0200 |
commit | 022a6968ae0ede1259141e32b8e32553dad7d824 (patch) | |
tree | bc9aa404e3bf7d6778a81b168fc6c9743531ceab /gocryptfs | |
parent | 552c32c5e9378b85e52c420c4dd2d7ccc827556f (diff) |
Implement proper daemonization
The shell wrapper sends gocryptfs into the background and waits for SIGUSR1
Diffstat (limited to 'gocryptfs')
-rwxr-xr-x | gocryptfs | 19 |
1 files changed, 10 insertions, 9 deletions
@@ -1,9 +1,13 @@ #!/bin/bash -# Simple wrapper that runs the gocryptfs process in the background +# Shell wrapper that runs the gocryptfs process in the background +# and exits on SIGUSR1 set -eu +trap "exit 0" SIGUSR1 +shopt -u huponexit + dir=$(dirname "$0") main="$dir/gocryptfs_main/gocryptfs_main" @@ -12,11 +16,8 @@ if [ ! -x $main ]; then exit 1 fi -# This needs user input and cannot run in the background -if [[ $* == *--init* ]]; then - "$main" $* -else - "$main" $* & - sleep 0.1 - disown -fi +# A backgrounded process gets /dev/null as stdin per default. +# Explicitly set stdin to the current stdin so we can ask the user for input. +"$main" $* < /proc/self/fd/0 & wait +# The "& wait" is neccessary because bash only processes signals when +# executing internal commands |