aboutsummaryrefslogtreecommitdiffstats
path: root/daemon/automount.c
diff options
context:
space:
mode:
Diffstat (limited to 'daemon/automount.c')
-rw-r--r--daemon/automount.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/daemon/automount.c b/daemon/automount.c
index a7f9582..f51b8dc 100644
--- a/daemon/automount.c
+++ b/daemon/automount.c
@@ -501,32 +501,29 @@ static void become_daemon(void)
int nullfd;
/* Don't BUSY any directories unneccessarily */
-
chdir("/");
/* Detach from foreground process */
-
- pid = fork();
- if ( pid > 0 )
- exit(0);
- else if ( pid < 0 ) {
- fprintf(stderr, "%s: Could not detach process\n", program);
- exit(1);
+ if ( !submount ) {
+ pid = fork();
+ if ( pid > 0 )
+ exit(0);
+ else if ( pid < 0 ) {
+ fprintf(stderr, "%s: Could not detach process\n", program);
+ exit(1);
+ }
}
/* Open syslog */
-
openlog("automount", LOG_PID, LOG_DAEMON);
/* Initialize global data */
-
my_pid = getpid();
/* Make our own process group for "magic" reason: processes that share
our pgrp see the raw filesystem behine the magic. So if we are a
submount, don't change -- otherwise we won't be able to actually
perform the mount. */
-
if ( !submount && setpgrp() ) {
syslog(LOG_CRIT, "setpgrp: %m");
exit(1);
@@ -534,7 +531,6 @@ static void become_daemon(void)
my_pgrp = getpgrp();
/* Redirect all our file descriptors to /dev/null */
-
if ( (nullfd = open("/dev/null", O_RDWR)) < 0 ) {
syslog(LOG_CRIT, "cannot open /dev/null: %m");
exit(1);
@@ -549,7 +545,6 @@ static void become_daemon(void)
close(nullfd);
/* Write pid file if requested */
-
if ( pid_file ) {
if ( (pidfp = fopen(pid_file, "wt")) ) {
fprintf(pidfp, "%lu\n", (unsigned long) my_pid);
@@ -784,6 +779,11 @@ int main(int argc, char *argv[])
if ( ap.exp_timeout )
alarm(ap.exp_timeout + my_pid % ap.exp_runfreq);
}
+
+ /* Initialization successful. If we're a submount, send outself SIGSTOP to let
+ our parent know that we have grown up and don't need supervision anymore. */
+ if ( submount )
+ kill(my_pid, SIGSTOP);
while ( !shutdown ) {
if (handle_packet() && errno != EINTR)