From: Ben Pfaff Date: Tue, 13 Jan 2009 00:49:55 +0000 (-0800) Subject: New function process_run(). X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=00451d80fae9f7cdfd1cd19886d8460c3971c112;p=openvswitch New function process_run(). --- diff --git a/lib/process.c b/lib/process.c index 6680ef8a..3315e361 100644 --- a/lib/process.c +++ b/lib/process.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2008 The Board of Trustees of The Leland Stanford +/* Copyright (c) 2008, 2009 The Board of Trustees of The Leland Stanford * Junior University * * We are making the OpenFlow specification and associated documentation @@ -263,6 +263,27 @@ process_status(const struct process *p) return p->status; } +int +process_run(char **argv, int *status) +{ + struct process *p; + int retval; + + retval = process_start(argv, NULL, 0, &p); + if (retval) { + *status = 0; + return retval; + } + + while (!process_exited(p)) { + process_wait(p); + poll_block(); + } + *status = process_status(p); + process_destroy(p); + return 0; +} + /* Given 'status', which is a process status in the form reported by waitpid(2) * and returned by process_status(), returns a string describing how the * process terminated. The caller is responsible for freeing the string when diff --git a/lib/process.h b/lib/process.h index 22601009..b9c80913 100644 --- a/lib/process.h +++ b/lib/process.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2008 The Board of Trustees of The Leland Stanford +/* Copyright (c) 2008, 2009 The Board of Trustees of The Leland Stanford * Junior University * * We are making the OpenFlow specification and associated documentation @@ -44,6 +44,8 @@ int process_start(char **argv, const int *keep_fds, size_t n_keep_fds, void process_destroy(struct process *); int process_kill(const struct process *, int signr); +int process_run(char **argv, int *status); + pid_t process_pid(const struct process *); const char *process_name(const struct process *); bool process_exited(struct process *);