]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
utils.c: Add lxc_wait_for_pid_status routine that returns exit code
authorChristian Seiler <christian@iwakd.de>
Mon, 20 May 2013 15:54:21 +0000 (17:54 +0200)
committerSerge Hallyn <serge.hallyn@ubuntu.com>
Mon, 20 May 2013 22:35:42 +0000 (17:35 -0500)
Signed-off-by: Christian Seiler <christian@iwakd.de>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
src/lxc/utils.c
src/lxc/utils.h

index cf42c385cfd49a4ddcad375406a3e38dac3a77a8..66bd19d093d389df5ae697a671f8f223f2f254b3 100644 (file)
@@ -265,3 +265,19 @@ again:
                return -1;
        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;
+}
index 09af34ac36a51442b883bde7fb5275175de465ef..be1a8a8c30929cccc9257726d545e674d0a8f13d 100644 (file)
@@ -23,6 +23,8 @@
 #ifndef _utils_h
 #define _utils_h
 
+#include <sys/types.h>
+
 extern int lxc_setup_fs(void);
 extern int get_u16(unsigned short *val, const char *arg, int base);
 extern int mkdir_p(const char *dir, mode_t mode);
@@ -64,5 +66,6 @@ extern int __build_bug_on_failed;
  * wait on a child we forked
  */
 extern int wait_for_pid(pid_t pid);
+extern int lxc_wait_for_pid_status(pid_t pid);
 
 #endif