mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-31 06:15:24 +00:00
crtools: write a pid of a root task in a specified file
When we restore a pid namespace the root task will get some unknown pid in the original (i.e. -- the ns crtools a launched from) one. To find this pid out one can use this option -- it will make the pid obtained by the new init to be written into a pid file. Signed-off-by: Andrey Vagin <avagin@openvz.org> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
committed by
Pavel Emelyanov
parent
a5ac06f503
commit
aabb56bd66
14
cr-restore.c
14
cr-restore.c
@@ -547,6 +547,20 @@ static inline int fork_with_pid(struct pstree_item *item, unsigned long ns_clone
|
||||
|
||||
if (ca.clone_flags & CLONE_NEWPID)
|
||||
item->pid.real = ret;
|
||||
|
||||
if (opts.pidfile && root_item == item) {
|
||||
int fd;
|
||||
|
||||
fd = open(opts.pidfile, O_WRONLY | O_TRUNC | O_CREAT, 0600);
|
||||
if (fd == -1) {
|
||||
pr_perror("Can't open %s", opts.pidfile);
|
||||
kill(ret, SIGKILL);
|
||||
} else {
|
||||
dprintf(fd, "%d", ret);
|
||||
close(fd);
|
||||
}
|
||||
}
|
||||
|
||||
err_unlock:
|
||||
if (flock(ca.fd, LOCK_UN))
|
||||
pr_perror("%d: Can't unlock %s", pid, LAST_PID_PATH);
|
||||
|
Reference in New Issue
Block a user