From: Ben Pfaff Date: Wed, 8 May 2013 21:31:55 +0000 (-0700) Subject: process: Remove unused features from process_start(). X-Git-Tag: sliver-openvswitch-1.10.90-3~6^2~140 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=e1208bc494f2004c0ef0f8bc5e69183debfafedc;hp=21f0192507c8e14e4f43501104f7fc1d185136ae;p=sliver-openvswitch.git process: Remove unused features from process_start(). Signed-off-by: Ben Pfaff Acked-by: Ethan Jackson --- diff --git a/lib/process.c b/lib/process.c index ccba97a96..41023083b 100644 --- a/lib/process.c +++ b/lib/process.c @@ -59,7 +59,6 @@ static bool sigchld_is_blocked(void); static void block_sigchld(sigset_t *); static void unblock_sigchld(const sigset_t *); static void sigchld_handler(int signr OVS_UNUSED); -static bool is_member(int x, const int *array, size_t); /* Initializes the process subsystem (if it is not already initialized). Calls * exit() if initialization fails. @@ -174,20 +173,15 @@ process_register(const char *name, pid_t pid) * variable to find the program to execute. * * All file descriptors are closed before executing the subprocess, except for - * fds 0, 1, and 2 and the 'n_keep_fds' fds listed in 'keep_fds'. Also, any of - * the 'n_null_fds' fds listed in 'null_fds' are replaced by /dev/null. + * fds 0, 1, and 2. * * Returns 0 if successful, otherwise a positive errno value indicating the * error. If successful, '*pp' is assigned a new struct process that may be * used to query the process's status. On failure, '*pp' is set to NULL. */ int -process_start(char **argv, - const int keep_fds[], size_t n_keep_fds, - const int null_fds[], size_t n_null_fds, - struct process **pp) +process_start(char **argv, struct process **pp) { sigset_t oldsigs; - int nullfd; pid_t pid; int error; @@ -198,15 +192,6 @@ process_start(char **argv, return error; } - if (n_null_fds) { - nullfd = get_null_fd(); - if (nullfd < 0) { - return -nullfd; - } - } else { - nullfd = -1; - } - block_sigchld(&oldsigs); pid = fork(); if (pid < 0) { @@ -225,18 +210,8 @@ process_start(char **argv, fatal_signal_fork(); unblock_sigchld(&oldsigs); - for (fd = 0; fd < fd_max; fd++) { - if (is_member(fd, null_fds, n_null_fds)) { - dup2(nullfd, fd); - } else if (fd >= 3 && fd != nullfd - && !is_member(fd, keep_fds, n_keep_fds)) { - close(fd); - } - } - if (nullfd >= 0 - && !is_member(nullfd, keep_fds, n_keep_fds) - && !is_member(nullfd, null_fds, n_null_fds)) { - close(nullfd); + for (fd = 3; fd < fd_max; fd++) { + close(fd); } execvp(argv[0], argv); fprintf(stderr, "execvp(\"%s\") failed: %s\n", @@ -401,19 +376,6 @@ sigchld_handler(int signr OVS_UNUSED) ignore(write(fds[1], "", 1)); } -static bool -is_member(int x, const int *array, size_t n) -{ - size_t i; - - for (i = 0; i < n; i++) { - if (array[i] == x) { - return true; - } - } - return false; -} - static bool sigchld_is_blocked(void) { diff --git a/lib/process.h b/lib/process.h index 45e2a0039..6d1410b96 100644 --- a/lib/process.h +++ b/lib/process.h @@ -23,10 +23,7 @@ struct process; void process_init(void); char *process_escape_args(char **argv); -int process_start(char **argv, - const int *keep_fds, size_t n_keep_fds, - const int *null_fds, size_t n_null_fds, - struct process **); +int process_start(char **argv, struct process **); void process_destroy(struct process *); int process_kill(const struct process *, int signr); diff --git a/ovsdb/ovsdb-server.c b/ovsdb/ovsdb-server.c index 1ba7c3cfc..b9afd8c3e 100644 --- a/ovsdb/ovsdb-server.c +++ b/ovsdb/ovsdb-server.c @@ -169,7 +169,7 @@ main(int argc, char *argv[]) run_argv[2] = run_command; run_argv[3] = NULL; - retval = process_start(run_argv, NULL, 0, NULL, 0, &run_process); + retval = process_start(run_argv, &run_process); if (retval) { ovs_fatal(retval, "%s: process failed to start", run_command); }