void do_dump(char *filename, int flags) { int fd, r; printf("Dumping to: %s\n", filename); fd = open(filename, O_WRONLY|O_CREAT|O_TRUNC, DUMPMODE); if (fd == -1) { perror("open"); exit(1); } r = vmadump(fd,flags); printf("vmadump(%d,0x%x)=%d\n", fd, flags, r); if (r == -1) { perror("VMAD_DO_DUMP"); exit(1); } close(fd); if (r) { printf("dump complete - exiting.\n"); exit(0); } /* r == 0... Which means that we were dumped and we're getting * here because we've been undumped. */ printf("Whoo! I've been undumped! Kick ass!\n"); printf("New pid: %d\n", (int) getpid()); test_mm(); exit(0); }
int do_dump(char *filename, int flags) { int fd, r; fd = open(filename, O_WRONLY|O_CREAT|O_TRUNC, DUMPMODE); if (fd == -1) { perror("open"); exit(1); } r = vmadump(fd,flags); if (r == -1) { perror("VMAD_DO_DUMP"); exit(1); } close(fd); return r; }