/*
- *
* Copyright © 2014 Tycho Andersen <tycho.andersen@canonical.com>.
* Copyright © 2014 Canonical Ltd.
*
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#include <stdio.h>
+#define _GNU_SOURCE
#include <errno.h>
+#include <stdio.h>
+#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <lxc/lxccontainer.h>
-#include "log.h"
-#include "config.h"
-#include "lxc.h"
#include "arguments.h"
-#include "utils.h"
+#include "tool_utils.h"
static char *checkpoint_dir = NULL;
static bool stop = false;
if (lxc_log_init(&log))
exit(EXIT_FAILURE);
- lxc_log_options_no_override();
-
/* REMOVE IN LXC 3.0 */
setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0);
#endif
+int wait_for_pid(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;
+ if (!WIFEXITED(status) || WEXITSTATUS(status) != 0)
+ return -1;
+ return 0;
+}
+
int lxc_wait_for_pid_status(pid_t pid)
{
int status, ret;
}
#endif
+extern int wait_for_pid(pid_t pid);
extern int lxc_wait_for_pid_status(pid_t pid);
extern int lxc_safe_int(const char *numstr, int *converted);
extern int lxc_safe_long(const char *numstr, long int *converted);