From 79742298672dcf4191c96993d8f7ea77e4618f0e Mon Sep 17 00:00:00 2001 From: Radostin Stoyanov Date: Tue, 22 Dec 2020 12:15:54 +0000 Subject: [PATCH] criu-ns: Handle restore-detached option The criu-ns script creates a new PID namespace where criu is the "init" process. When using the --restore-detached option with criu-ns, users expect criu-ns to exit without killing the restored process tree. Thus, criu-ns should not pass the --restore-detached to criu to prevent it from terminating, and it should exit instead of waiting for criu's exit status. Resolves #1278 Suggested-by: Andrei Vagin Signed-off-by: Radostin Stoyanov --- scripts/criu-ns | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/scripts/criu-ns b/scripts/criu-ns index f9623fb7f..0c753347b 100755 --- a/scripts/criu-ns +++ b/scripts/criu-ns @@ -88,10 +88,23 @@ def wrap_restore(): _errno = ctypes.get_errno() raise OSError(_errno, errno.errorcode[_errno]) + restore_detached = False + restore_args = sys.argv[1:] + if '-d' in restore_args: + restore_detached = True + restore_args.remove('-d') + if '--restore-detached' in restore_args: + restore_detached = True + restore_args.remove('--restore-detached') + criu_pid = os.fork() if criu_pid == 0: _mount_new_proc() - run_criu(sys.argv[1:]) + run_criu(restore_args) + + if restore_detached: + return 0 + return _wait_for_process_status(criu_pid)