nsenter waits for parent signal before forking
this allows the parent to place the process into cgroup first so it can track the children properly Docker-DCO-1.1-Signed-off-by: Daniel, Dao Quang Minh <dqminh89@gmail.com> (github: dqminh)
This commit is contained in:
parent
29ba9b3179
commit
9946e299af
|
@ -73,6 +73,11 @@ func ExecIn(container *libcontainer.Config, state *libcontainer.State, userArgs
|
||||||
return terminate(err)
|
return terminate(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// finish cgroups' setup, unblock the child process.
|
||||||
|
if _, err := parent.WriteString("1"); err != nil {
|
||||||
|
return terminate(err)
|
||||||
|
}
|
||||||
|
|
||||||
if err := json.NewEncoder(parent).Encode(container); err != nil {
|
if err := json.NewEncoder(parent).Encode(container); err != nil {
|
||||||
return terminate(err)
|
return terminate(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,6 +155,12 @@ void nsenter()
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// blocking until the parent placed the process inside correct cgroups.
|
||||||
|
unsigned char s;
|
||||||
|
if (read(3, &s, 1) != 1 || s != '1') {
|
||||||
|
pr_perror("failed to receive synchronization data from parent");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
// Setns on all supported namespaces.
|
// Setns on all supported namespaces.
|
||||||
char ns_dir[PATH_MAX];
|
char ns_dir[PATH_MAX];
|
||||||
memset(ns_dir, 0, PATH_MAX);
|
memset(ns_dir, 0, PATH_MAX);
|
||||||
|
|
Loading…
Reference in New Issue