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 <avagin@gmail.com>
Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
This commit is contained in:
Radostin Stoyanov 2020-12-22 12:15:54 +00:00 committed by Andrei Vagin
parent 6b375ed755
commit 7974229867

View file

@ -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)