Commit c797a220 by Christian Seiler Committed by Serge Hallyn

utils.c: Add lxc_wait_for_pid_status routine that returns exit code

parent 71b9b8ed
...@@ -265,3 +265,19 @@ again: ...@@ -265,3 +265,19 @@ again:
return -1; return -1;
return 0; return 0;
} }
int lxc_wait_for_pid_status(pid_t pid)
{
int status, ret;
again:
ret = waitpid(pid, &status, 0);
if (ret == -1) {
if (errno == EINTR)
goto again;
return -1;
}
if (ret != pid)
goto again;
return status;
}
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
#ifndef _utils_h #ifndef _utils_h
#define _utils_h #define _utils_h
#include <sys/types.h>
extern int lxc_setup_fs(void); extern int lxc_setup_fs(void);
extern int get_u16(unsigned short *val, const char *arg, int base); extern int get_u16(unsigned short *val, const char *arg, int base);
extern int mkdir_p(const char *dir, mode_t mode); extern int mkdir_p(const char *dir, mode_t mode);
...@@ -64,5 +66,6 @@ extern int __build_bug_on_failed; ...@@ -64,5 +66,6 @@ extern int __build_bug_on_failed;
* wait on a child we forked * wait on a child we forked
*/ */
extern int wait_for_pid(pid_t pid); extern int wait_for_pid(pid_t pid);
extern int lxc_wait_for_pid_status(pid_t pid);
#endif #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment