Commit caf67f1f authored by Pavel Emelyanov's avatar Pavel Emelyanov

scripts: Do not set -1 as root item pid

On restore root_item may exist, but its real pid is not yet resolved
Fixes e5e8f791.
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
Acked-by: 's avatarAndrew Vagin <avagin@virtuozzo.com>
parent 8a7a360d
......@@ -44,7 +44,6 @@ static int run_shell_scripts(const char *action)
int ret = 0;
struct script *script;
char image_dir[PATH_MAX];
char root_item_pid[16];
static unsigned env_set = 0;
#define ENV_IMGDIR 0x1
......@@ -65,12 +64,18 @@ static int run_shell_scripts(const char *action)
}
if (!(env_set & ENV_ROOTPID) && root_item) {
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;
int pid;
char root_item_pid[16];
pid = root_item->pid.real;
if (pid != -1) {
snprintf(root_item_pid, sizeof(root_item_pid), "%d", pid);
if (setenv("CRTOOLS_INIT_PID", root_item_pid, 1)) {
pr_perror("Can't set CRTOOLS_INIT_PID=%s", root_item_pid);
return -1;
}
env_set |= ENV_ROOTPID;
}
env_set |= ENV_ROOTPID;
}
list_for_each_entry(script, &scripts, node) {
......
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