Dump a process
To dump a process, run:
1 |
$ criu dump -D checkpoint -t 1234 |
where,
-D : directory to save image files
-t : PID of process to dump
Convert criu images to core dump
Continuing with the examples above where we dumped the process with PID 1234, we can generate the core dump with the crit utility that comes with criu:
1 |
$ crit core-dump -i checkpoint -o checkpoint |
where,
-i : input directory with criu images
-o : output directory for the core dump
To find the generate core dump file:
1 2 |
$ ls checkpoint/core.* core.45678 |
Check the information with readelf:
1 |
$ readelf -a core.45678 |
Start debugging with GDB:
1 |
$ gdb loop core.45678 |
Resume the process
To resume a process from dump files:
1 |
$ criu restore -d -D checkpoint |
where,
-d : detach criu from the process after resume
测试:
脚本 a.php
1 2 3 4 5 6 |
<?php $i = 0; while(1) { echo $i++, "\n"; sleep(1); } |
启动:
1 |
php a.php >/tmp/a.log 2>&1 0>/dev/null |
dump:
1 |
criu dump --shell-job -t 4774 |
restore:
1 |
criu restore -d -D . |
截屏:
参考: