summaryrefslogtreecommitdiff
path: root/lib/daemon.c
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2012-12-13 14:01:23 -0800
committerBen Pfaff <blp@nicira.com>2012-12-13 14:01:23 -0800
commit066f329e29d5ff0b97ef77a5711d87ed53eef73d (patch)
tree74798cdd53063c29edd57db8c6c16486d7166caf /lib/daemon.c
parented36537ebf48108accf21a8aa073279eceeafa98 (diff)
downloadopenvswitch-066f329e29d5ff0b97ef77a5711d87ed53eef73d.tar.gz
daemon: Start monitor process, not daemon process, in new session.
To keep control+C and other signals in the initiating session from killing the monitor process, we need to put the monitor process into its own session. However, until this point, we've only done that for the daemon processes that the monitor started, which means that control+C would kill the monitor but not the daemons that it launched. I don't know of a benefit to putting the monitor and daemon processes in different sessions, as opposed to one new session for both of them, so this change does the latter. daemonize_post_detach() is called from one additional context where we'd want to be in a new session, the worker_start() function, but that function is documented as to be called after daemonize_start(), in which case we will (after this commit) already have called setsid(), so no additional change is required there. Bug #14280. Reported-by: Gordon Good <ggood@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
Diffstat (limited to 'lib/daemon.c')
-rw-r--r--lib/daemon.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/daemon.c b/lib/daemon.c
index 25f2db72b..484919622 100644
--- a/lib/daemon.c
+++ b/lib/daemon.c
@@ -492,7 +492,9 @@ daemonize_start(void)
/* Running in parent process. */
exit(0);
}
+
/* Running in daemon or monitor process. */
+ setsid();
}
if (monitor) {
@@ -546,7 +548,6 @@ void
daemonize_post_detach(void)
{
if (detach) {
- setsid();
if (chdir_) {
ignore(chdir("/"));
}