diff options
author | Ben Pfaff <blp@nicira.com> | 2011-03-31 09:44:30 -0700 |
---|---|---|
committer | Ben Pfaff <blp@nicira.com> | 2011-04-04 10:58:55 -0700 |
commit | 00c08589876b7c1cd8f57e5ebb3e66bb164c5a3d (patch) | |
tree | 975fd01be03267487ef2fc4317484ada0a5c27b0 /lib/daemon.c | |
parent | af9a144207eb1b4fdfd735b29f90c41f80aa9a2e (diff) | |
download | openvswitch-00c08589876b7c1cd8f57e5ebb3e66bb164c5a3d.tar.gz |
daemon: Integrate checking for an existing pidfile into daemonize_start().
Until now, it has been the responsibility of an individual daemon to call
die_if_already_running() at an appropriate time. A long time ago, this
had to happen *before* daemonizing, because once the process daemonized
itself there was no way to report failure to the process that originally
started the daemon. With the introduction of daemonize_start(), this is
now possible, but we haven't been taking advantage of it.
Therefore, this commit integrates the die_if_already_running() call into
daemonize_start() and deletes the calls to it from individual daemons.
Diffstat (limited to 'lib/daemon.c')
-rw-r--r-- | lib/daemon.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/daemon.c b/lib/daemon.c index 173dabe6f..a9cada866 100644 --- a/lib/daemon.c +++ b/lib/daemon.c @@ -107,9 +107,9 @@ is_chdir_enabled(void) return chdir_; } -/* Normally, die_if_already_running() will terminate the program with a message - * if a locked pidfile already exists. If this function is called, - * die_if_already_running() will merely log a warning. */ +/* Normally, daemonize() or damonize_start() will terminate the program with a + * message if a locked pidfile already exists. If this function is called, an + * existing pidfile will be replaced, with a warning. */ void ignore_existing_pidfile(void) { @@ -141,7 +141,7 @@ daemon_set_monitor(void) /* If a locked pidfile exists, issue a warning message and, unless * ignore_existing_pidfile() has been called, terminate the program. */ -void +static void die_if_already_running(void) { pid_t pid; @@ -449,6 +449,7 @@ daemonize_start(void) /* Running in daemon process. */ } + die_if_already_running(); make_pidfile(); /* Make sure that the unixctl commands for vlog get registered in a |