X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=snapshot.cc;h=da478075c8b4f8bde0c4fdfb3bc499f44a79ace9;hb=103b2cae595a3744095dd8432b62b138f24ec9eb;hp=5069a1cf1147cb7afb07035cbf607c69daa2c284;hpb=217296360283e2a11affe53bb1c94c84814bc9f6;p=model-checker.git diff --git a/snapshot.cc b/snapshot.cc index 5069a1c..da47807 100644 --- a/snapshot.cc +++ b/snapshot.cc @@ -347,19 +347,19 @@ static void fork_snapshot_init(unsigned int numbackingpages, setcontext(&savedUserSnapshotContext); } } else { - int status; - int retVal; - - DEBUG("The process id of child is %d and the process id of this process is %d and snapshot id is %d\n", - forkedID, getpid(), snapshotid); - - do { - retVal = waitpid(forkedID, &status, 0); - } while (-1 == retVal && errno == EINTR); + DEBUG("parent PID: %d, child PID: %d, snapshot ID: %d\n", + getpid(), forkedID, snapshotid); + + while (waitpid(forkedID, NULL, 0) < 0) { + /* waitpid() may be interrupted */ + if (errno != EINTR) { + perror("waitpid"); + exit(EXIT_FAILURE); + } + } - if (fork_snap->mIDToRollback != snapshotid) { + if (fork_snap->mIDToRollback != snapshotid) exit(EXIT_SUCCESS); - } rollback = true; } }