<div dir="ltr">Acked-by: Ansis Atteka <<a href="mailto:aatteka@nicira.com">aatteka@nicira.com</a>></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Jun 5, 2013 at 1:05 PM, Ben Pfaff <span dir="ltr"><<a href="mailto:blp@nicira.com" target="_blank">blp@nicira.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">They are unused.<br>
<br>
Signed-off-by: Ben Pfaff <<a href="mailto:blp@nicira.com">blp@nicira.com</a>><br>
---<br>
lib/process.c | 227 ---------------------------------------------------------<br>
lib/process.h | 8 --<br>
2 files changed, 0 insertions(+), 235 deletions(-)<br>
<br>
diff --git a/lib/process.c b/lib/process.c<br>
index 0aa1842..ccba97a 100644<br>
--- a/lib/process.c<br>
+++ b/lib/process.c<br>
@@ -36,8 +36,6 @@<br>
<br>
VLOG_DEFINE_THIS_MODULE(process);<br>
<br>
-COVERAGE_DEFINE(process_run);<br>
-COVERAGE_DEFINE(process_run_capture);<br>
COVERAGE_DEFINE(process_sigchld);<br>
COVERAGE_DEFINE(process_start);<br>
<br>
@@ -311,32 +309,6 @@ process_status(const struct process *p)<br>
return p->status;<br>
}<br>
<br>
-int<br>
-process_run(char **argv,<br>
- const int keep_fds[], size_t n_keep_fds,<br>
- const int null_fds[], size_t n_null_fds,<br>
- int *status)<br>
-{<br>
- struct process *p;<br>
- int retval;<br>
-<br>
- COVERAGE_INC(process_run);<br>
- retval = process_start(argv, keep_fds, n_keep_fds, null_fds, n_null_fds,<br>
- &p);<br>
- if (retval) {<br>
- *status = 0;<br>
- return retval;<br>
- }<br>
-<br>
- while (!process_exited(p)) {<br>
- process_wait(p);<br>
- poll_block();<br>
- }<br>
- *status = process_status(p);<br>
- process_destroy(p);<br>
- return 0;<br>
-}<br>
-<br>
/* Given 'status', which is a process status in the form reported by waitpid(2)<br>
* and returned by process_status(), returns a string describing how the<br>
* process terminated. The caller is responsible for freeing the string when<br>
@@ -403,205 +375,6 @@ process_search_path(const char *name)<br>
return NULL;<br>
}<br>
<br>
-/* process_run_capture() and supporting functions. */<br>
-<br>
-struct stream {<br>
- size_t max_size;<br>
- struct ds log;<br>
- int fds[2];<br>
-};<br>
-<br>
-static int<br>
-stream_open(struct stream *s, size_t max_size)<br>
-{<br>
- int error;<br>
-<br>
- s->max_size = max_size;<br>
- ds_init(&s->log);<br>
- if (pipe(s->fds)) {<br>
- VLOG_WARN("failed to create pipe: %s", strerror(errno));<br>
- return errno;<br>
- }<br>
- error = set_nonblocking(s->fds[0]);<br>
- if (error) {<br>
- close(s->fds[0]);<br>
- close(s->fds[1]);<br>
- }<br>
- return error;<br>
-}<br>
-<br>
-static void<br>
-stream_read(struct stream *s)<br>
-{<br>
- if (s->fds[0] < 0) {<br>
- return;<br>
- }<br>
-<br>
- for (;;) {<br>
- char buffer[512];<br>
- int error;<br>
- size_t n;<br>
-<br>
- error = read_fully(s->fds[0], buffer, sizeof buffer, &n);<br>
- ds_put_buffer(&s->log, buffer, n);<br>
- if (error) {<br>
- if (error == EAGAIN || error == EWOULDBLOCK) {<br>
- return;<br>
- } else {<br>
- if (error != EOF) {<br>
- VLOG_WARN("error reading subprocess pipe: %s",<br>
- strerror(error));<br>
- }<br>
- break;<br>
- }<br>
- } else if (s->log.length > s->max_size) {<br>
- VLOG_WARN("subprocess output overflowed %zu-byte buffer",<br>
- s->max_size);<br>
- break;<br>
- }<br>
- }<br>
- close(s->fds[0]);<br>
- s->fds[0] = -1;<br>
-}<br>
-<br>
-static void<br>
-stream_wait(struct stream *s)<br>
-{<br>
- if (s->fds[0] >= 0) {<br>
- poll_fd_wait(s->fds[0], POLLIN);<br>
- }<br>
-}<br>
-<br>
-static void<br>
-stream_close(struct stream *s)<br>
-{<br>
- ds_destroy(&s->log);<br>
- if (s->fds[0] >= 0) {<br>
- close(s->fds[0]);<br>
- }<br>
- if (s->fds[1] >= 0) {<br>
- close(s->fds[1]);<br>
- }<br>
-}<br>
-<br>
-/* Starts the process whose arguments are given in the null-terminated array<br>
- * 'argv' and waits for it to exit. On success returns 0 and stores the<br>
- * process exit value (suitable for passing to process_status_msg()) in<br>
- * '*status'. On failure, returns a positive errno value and stores 0 in<br>
- * '*status'.<br>
- *<br>
- * If 'stdout_log' is nonnull, then the subprocess's output to stdout (up to a<br>
- * limit of 'log_max' bytes) is captured in a memory buffer, which<br>
- * when this function returns 0 is stored as a null-terminated string in<br>
- * '*stdout_log'. The caller is responsible for freeing '*stdout_log' (by<br>
- * passing it to free()). When this function returns an error, '*stdout_log'<br>
- * is set to NULL.<br>
- *<br>
- * If 'stderr_log' is nonnull, then it is treated like 'stdout_log' except<br>
- * that it captures the subprocess's output to stderr. */<br>
-int<br>
-process_run_capture(char **argv, char **stdout_log, char **stderr_log,<br>
- size_t max_log, int *status)<br>
-{<br>
- struct stream s_stdout, s_stderr;<br>
- sigset_t oldsigs;<br>
- pid_t pid;<br>
- int error;<br>
-<br>
- COVERAGE_INC(process_run_capture);<br>
- if (stdout_log) {<br>
- *stdout_log = NULL;<br>
- }<br>
- if (stderr_log) {<br>
- *stderr_log = NULL;<br>
- }<br>
- *status = 0;<br>
- error = process_prestart(argv);<br>
- if (error) {<br>
- return error;<br>
- }<br>
-<br>
- error = stream_open(&s_stdout, max_log);<br>
- if (error) {<br>
- return error;<br>
- }<br>
-<br>
- error = stream_open(&s_stderr, max_log);<br>
- if (error) {<br>
- stream_close(&s_stdout);<br>
- return error;<br>
- }<br>
-<br>
- block_sigchld(&oldsigs);<br>
- pid = fork();<br>
- if (pid < 0) {<br>
- error = errno;<br>
-<br>
- unblock_sigchld(&oldsigs);<br>
- VLOG_WARN("fork failed: %s", strerror(error));<br>
-<br>
- stream_close(&s_stdout);<br>
- stream_close(&s_stderr);<br>
- *status = 0;<br>
- return error;<br>
- } else if (pid) {<br>
- /* Running in parent process. */<br>
- struct process *p;<br>
-<br>
- p = process_register(argv[0], pid);<br>
- unblock_sigchld(&oldsigs);<br>
-<br>
- close(s_stdout.fds[1]);<br>
- close(s_stderr.fds[1]);<br>
- while (!process_exited(p)) {<br>
- stream_read(&s_stdout);<br>
- stream_read(&s_stderr);<br>
-<br>
- stream_wait(&s_stdout);<br>
- stream_wait(&s_stderr);<br>
- process_wait(p);<br>
- poll_block();<br>
- }<br>
- stream_read(&s_stdout);<br>
- stream_read(&s_stderr);<br>
-<br>
- if (stdout_log) {<br>
- *stdout_log = ds_steal_cstr(&s_stdout.log);<br>
- }<br>
- if (stderr_log) {<br>
- *stderr_log = ds_steal_cstr(&s_stderr.log);<br>
- }<br>
-<br>
- stream_close(&s_stdout);<br>
- stream_close(&s_stderr);<br>
-<br>
- *status = process_status(p);<br>
- process_destroy(p);<br>
- return 0;<br>
- } else {<br>
- /* Running in child process. */<br>
- int max_fds;<br>
- int i;<br>
-<br>
- fatal_signal_fork();<br>
- unblock_sigchld(&oldsigs);<br>
-<br>
- dup2(get_null_fd(), 0);<br>
- dup2(s_stdout.fds[1], 1);<br>
- dup2(s_stderr.fds[1], 2);<br>
-<br>
- max_fds = get_max_fds();<br>
- for (i = 3; i < max_fds; i++) {<br>
- close(i);<br>
- }<br>
-<br>
- execvp(argv[0], argv);<br>
- fprintf(stderr, "execvp(\"%s\") failed: %s\n",<br>
- argv[0], strerror(errno));<br>
- exit(EXIT_FAILURE);<br>
- }<br>
-}<br>
-<br>
static void<br>
sigchld_handler(int signr OVS_UNUSED)<br>
{<br>
diff --git a/lib/process.h b/lib/process.h<br>
index d40c1ac..45e2a00 100644<br>
--- a/lib/process.h<br>
+++ b/lib/process.h<br>
@@ -30,11 +30,6 @@ int process_start(char **argv,<br>
void process_destroy(struct process *);<br>
int process_kill(const struct process *, int signr);<br>
<br>
-int process_run(char **argv,<br>
- const int *keep_fds, size_t n_keep_fds,<br>
- const int *null_fds, size_t n_null_fds,<br>
- int *status);<br>
-<br>
pid_t process_pid(const struct process *);<br>
const char *process_name(const struct process *);<br>
bool process_exited(struct process *);<br>
@@ -45,7 +40,4 @@ void process_wait(struct process *);<br>
<br>
char *process_search_path(const char *);<br>
<br>
-int process_run_capture(char **argv, char **stdout_log, char **stderr_log,<br>
- size_t max_log, int *status);<br>
-<br>
#endif /* process.h */<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.7.2.5<br>
<br>
_______________________________________________<br>
dev mailing list<br>
<a href="mailto:dev@openvswitch.org">dev@openvswitch.org</a><br>
<a href="http://openvswitch.org/mailman/listinfo/dev" target="_blank">http://openvswitch.org/mailman/listinfo/dev</a><br>
</font></span></blockquote></div><br></div>