unlink the extra tmp file generated
[c11tester.git] / snapshot.cc
index 2402bbde894f8a2134741636f24ebc8882aac306..d287319a5f0bda5f18438b2e8354e60ab755e4da 100644 (file)
@@ -14,6 +14,9 @@
 #include "context.h"
 #include "model.h"
 
+
+#if USE_MPROTECT_SNAPSHOT
+
 /** PageAlignedAdressUpdate return a page aligned address for the
  * address being added as a side effect the numBytes are also changed.
  */
@@ -22,8 +25,6 @@ static void * PageAlignAddressUpward(void *addr)
        return (void *)((((uintptr_t)addr) + PAGESIZE - 1) & ~(PAGESIZE - 1));
 }
 
-#if USE_MPROTECT_SNAPSHOT
-
 /* Each SnapShotRecord lists the firstbackingpage that must be written to
  * revert to that snapshot */
 struct SnapShotRecord {
@@ -401,8 +402,13 @@ static void fork_loop() {
                                }
                        }
 
-                       if (fork_snap->mIDToRollback != snapshotid)
+                       if (fork_snap->mIDToRollback != snapshotid) {
+                               char filename[256];
+                               snprintf_(filename, sizeof(filename), "C11FuzzerTmp%d", forkedID);
+                               unlink(filename);
+
                                _Exit(EXIT_SUCCESS);
+                       }
                }
        }
 }