From: Christian Brauner Date: Fri, 12 Jan 2018 13:02:10 +0000 (+0100) Subject: tools: move lxc-checkpoint to API symbols only X-Git-Tag: lxc-3.0.0.beta1~36^2~23 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=78485176fd49b03b8374aa449e11f60a4866ae09;p=thirdparty%2Flxc.git tools: move lxc-checkpoint to API symbols only Closes #2073. Signed-off-by: Christian Brauner --- diff --git a/src/lxc/tools/lxc_checkpoint.c b/src/lxc/tools/lxc_checkpoint.c index 8f93934b3..f3f9e7415 100644 --- a/src/lxc/tools/lxc_checkpoint.c +++ b/src/lxc/tools/lxc_checkpoint.c @@ -1,5 +1,4 @@ /* - * * Copyright © 2014 Tycho Andersen . * Copyright © 2014 Canonical Ltd. * @@ -17,19 +16,18 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include +#define _GNU_SOURCE #include +#include +#include #include #include #include #include -#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; @@ -253,8 +251,6 @@ int main(int argc, char *argv[]) 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); diff --git a/src/lxc/tools/tool_utils.c b/src/lxc/tools/tool_utils.c index 39b388161..4b4dad0b4 100644 --- a/src/lxc/tools/tool_utils.c +++ b/src/lxc/tools/tool_utils.c @@ -276,6 +276,24 @@ out: #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; diff --git a/src/lxc/tools/tool_utils.h b/src/lxc/tools/tool_utils.h index 9f0e6a01f..f900f037c 100644 --- a/src/lxc/tools/tool_utils.h +++ b/src/lxc/tools/tool_utils.h @@ -123,6 +123,7 @@ static inline int lxc_caps_init(void) { } #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);