Skip to content

Instantly share code, notes, and snippets.

@mbien
Last active November 14, 2020 02:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mbien/176f699a161ce15e15f1cfd89147e1e6 to your computer and use it in GitHub Desktop.
Save mbien/176f699a161ce15e15f1cfd89147e1e6 to your computer and use it in GitHub Desktop.
minimal criu dump
#include <stdio.h>
#include <stdlib.h>
#include <criu.h>
#include <fcntl.h>
// requires setcap cap_checkpoint_restore,cap_sys_ptrace+eip /path/to/exec
int main(int argc, char** argv) {
printf("hello criu\n");
criu_init_opts();
criu_set_log_file("dump.log");
criu_set_log_level(4);
criu_set_shell_job(true);
criu_set_leave_running(true);
int fd = open("/tmp/cdump", O_DIRECTORY);
criu_set_images_dir_fd(fd);
printf("pre-dump\n");
int ret = criu_dump();
printf("ret: %i\n", ret);
printf("post-dump\n");
return (EXIT_SUCCESS);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment