From 40b68eb405f1a67b04136c9d22dbd0b8d229abcb Mon Sep 17 00:00:00 2001 From: Stanislav Kinsburskiy Date: Tue, 12 Apr 2016 12:50:00 +0300 Subject: [PATCH] cr-restore: set NS_PID environment variable before "post-resume" hook The only one (so far) "post-resume" script needs some pid to join its namespaces. Let it be containers root. v4: 1) Enviroonment setup has been was moved to run_scripts 2) Environment variable NS_PID was renamed to CRTOOLS_INIT_PID Signed-off-by: Stanislav Kinsburskiy Signed-off-by: Pavel Emelyanov --- criu/action-scripts.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/criu/action-scripts.c b/criu/action-scripts.c index b1f7952a1..a6a11bfc5 100644 --- a/criu/action-scripts.c +++ b/criu/action-scripts.c @@ -29,6 +29,7 @@ int run_scripts(enum script_actions act) int ret = 0; char image_dir[PATH_MAX]; const char *action = action_names[act]; + char root_item_pid[16]; pr_debug("Running %s scripts\n", action); @@ -46,6 +47,12 @@ int run_scripts(enum script_actions act) return -1; } + snprintf(root_item_pid, sizeof(root_item_pid), "%d", root_item->pid.real); + if (setenv("CRTOOLS_INIT_PID", root_item_pid, 1)) { + pr_perror("Can't set CRTOOLS_INIT_PID=%s", root_item_pid); + return -1; + } + list_for_each_entry(script, &opts.scripts, node) { if (script->path == SCRIPT_RPC_NOTIFY) { pr_debug("\tRPC\n");