aboutsummaryrefslogtreecommitdiff
path: root/lib/daemon.c
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2013-06-19 13:07:35 -0700
committerBen Pfaff <blp@nicira.com>2013-06-28 16:09:37 -0700
commit728a8b141ff670d0b98b61bd88a6bb7a9c719e26 (patch)
tree992f96dc5d314fccae032d15ede60e68c66fdefb /lib/daemon.c
parent1514b275558304c63bc3838c2da5c4be0c1cbef0 (diff)
ovs-thread: Add support for various thread-related assertions.
Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Ethan Jackson <ethan@nicira.com>
Diffstat (limited to 'lib/daemon.c')
-rw-r--r--lib/daemon.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/lib/daemon.c b/lib/daemon.c
index e12bc14a..56b32b80 100644
--- a/lib/daemon.c
+++ b/lib/daemon.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012 Nicira, Inc.
+ * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,6 +29,7 @@
#include "fatal-signal.h"
#include "dirs.h"
#include "lockfile.h"
+#include "ovs-thread.h"
#include "process.h"
#include "socket-util.h"
#include "timeval.h"
@@ -88,6 +89,7 @@ make_pidfile_name(const char *name)
void
set_pidfile(const char *name)
{
+ assert_single_threaded();
free(pidfile);
pidfile = make_pidfile_name(name);
}
@@ -280,9 +282,7 @@ daemonize(void)
pid_t
fork_and_clean_up(void)
{
- pid_t pid;
-
- pid = fork();
+ pid_t pid = xfork();
if (pid > 0) {
/* Running in parent process. */
fatal_signal_fork();
@@ -290,10 +290,7 @@ fork_and_clean_up(void)
/* Running in child process. */
time_postfork();
lockfile_postfork();
- } else {
- VLOG_FATAL("fork failed (%s)", strerror(errno));
}
-
return pid;
}
@@ -504,6 +501,7 @@ close_standard_fds(void)
void
daemonize_start(void)
{
+ assert_single_threaded();
daemonize_fd = -1;
if (detach) {