X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Fprocess.c;h=5dd34b3a7c8c4ca9ed0b7e5243fb92745efce07f;hb=e3b406a6b6e2b731f1c1a98c06358711ba731705;hp=520502a855db00392e550e8b97b291175b8411aa;hpb=57d90319a6deeb59e23227878a39f92470ac3e2b;p=sliver-openvswitch.git diff --git a/lib/process.c b/lib/process.c index 520502a85..5dd34b3a7 100644 --- a/lib/process.c +++ b/lib/process.c @@ -28,6 +28,7 @@ #include "dynamic-string.h" #include "fatal-signal.h" #include "list.h" +#include "ovs-thread.h" #include "poll-loop.h" #include "signals.h" #include "socket-util.h" @@ -36,7 +37,6 @@ VLOG_DEFINE_THIS_MODULE(process); -COVERAGE_DEFINE(process_sigchld); COVERAGE_DEFINE(process_start); struct process { @@ -60,6 +60,8 @@ static void sigchld_handler(int signr OVS_UNUSED); /* Initializes the process subsystem (if it is not already initialized). Calls * exit() if initialization fails. * + * This function may not be called after creating any additional threads. + * * Calling this function is optional; it will be called automatically by * process_start() if necessary. Calling it explicitly allows the client to * prevent the process from exiting at an unexpected time. */ @@ -69,6 +71,7 @@ process_init(void) static bool inited; struct sigaction sa; + assert_single_threaded(); if (inited) { return; } @@ -164,6 +167,8 @@ process_register(const char *name, pid_t pid) * argv[0] is used as the name of the process. Searches the PATH environment * variable to find the program to execute. * + * This function may not be called after creating any additional threads. + * * All file descriptors are closed before executing the subprocess, except for * fds 0, 1, and 2. * @@ -176,6 +181,8 @@ process_start(char **argv, struct process **pp) pid_t pid; int error; + assert_single_threaded(); + *pp = NULL; COVERAGE_INC(process_start); error = process_prestart(argv); @@ -185,7 +192,7 @@ process_start(char **argv, struct process **pp) pid = fork(); if (pid < 0) { - VLOG_WARN("fork failed: %s", strerror(errno)); + VLOG_WARN("fork failed: %s", ovs_strerror(errno)); return errno; } else if (pid) { /* Running in parent process. */ @@ -202,7 +209,7 @@ process_start(char **argv, struct process **pp) } execvp(argv[0], argv); fprintf(stderr, "execvp(\"%s\") failed: %s\n", - argv[0], strerror(errno)); + argv[0], ovs_strerror(errno)); _exit(1); } } @@ -308,7 +315,7 @@ process_run(void) p->exited = true; p->status = status; } else if (retval < 0) { - VLOG_WARN("waitpid: %s", strerror(errno)); + VLOG_WARN("waitpid: %s", ovs_strerror(errno)); p->exited = true; p->status = -1; }