Skip to content

Commit 9e5fbcd

Browse files
unichronicavagin
authored andcommitted
pycriu: Fix self-dump failure with explicit PID
When `opts.pid` is explicitly set to `os.getpid()`, `pycriu` fails to daemonize the `criu` process. This causes `criu` to run as a child of the dumped process, leading to the error "The criu itself is within dumped tree". This can be fixed by modifying `_send_req_and_recv_resp` to check if the target PID matches the current process PID. If so, it enables daemon mode, ensuring `criu` is detached and the dump succeeds. Signed-off-by: unichronic <ishuvam.pal@gmail.com>
1 parent 21a6758 commit 9e5fbcd

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/pycriu/criu.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ def _send_req_and_recv_resp(self, req):
242242
# process resources from its own if criu is located in a same
243243
# process tree it is trying to dump.
244244
daemon = False
245-
if req.type == rpc.DUMP and not req.opts.HasField('pid'):
245+
if req.type == rpc.DUMP and (not req.opts.HasField('pid') or req.opts.pid == os.getpid()):
246246
daemon = True
247247

248248
try:

0 commit comments

Comments
 (0)