Acked-by: Ethan Jackson <et...@nicira.com>
On Wed, Jun 5, 2013 at 1:05 PM, Ben Pfaff <b...@nicira.com> wrote: > Signed-off-by: Ben Pfaff <b...@nicira.com> > --- > lib/process.c | 46 ++++------------------------------------------ > lib/process.h | 5 +---- > ovsdb/ovsdb-server.c | 2 +- > 3 files changed, 6 insertions(+), 47 deletions(-) > > diff --git a/lib/process.c b/lib/process.c > index ccba97a..4102308 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", > @@ -402,19 +377,6 @@ sigchld_handler(int signr OVS_UNUSED) > } > > 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) > { > sigset_t sigs; > diff --git a/lib/process.h b/lib/process.h > index 45e2a00..6d1410b 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 1ba7c3c..b9afd8c 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); > } > -- > 1.7.2.5 > > _______________________________________________ > dev mailing list > dev@openvswitch.org > http://openvswitch.org/mailman/listinfo/dev _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev