aboutsummaryrefslogtreecommitdiffstats
path: root/daemon
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>1998-03-27 06:14:10 +0000
committerH. Peter Anvin <hpa@zytor.com>1998-03-27 06:14:10 +0000
commitf5888e2e45e3170f0003fee359f35f839ba468ea (patch)
treeb14e0f5e838919129047e525df21086450e3a6cc /daemon
parentc8c6aec4a542e41b899bd1f89ef335b3f5b53aff (diff)
downloadautofs3-f5888e2e45e3170f0003fee359f35f839ba468ea.tar.gz
autofs3-f5888e2e45e3170f0003fee359f35f839ba468ea.tar.xz
autofs3-f5888e2e45e3170f0003fee359f35f839ba468ea.zip
Change submount synchronization to not detach (we'll get detached when
the parent process exits); use signals for proper synchronization.
Diffstat (limited to 'daemon')
-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)