about summary refs log tree commit diff
path: root/src/afl-fuzz.c
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2020-06-14 16:08:58 +0200
committervan Hauser <vh@thc.org>2020-06-14 16:08:58 +0200
commitab142282a32f93725926d59899ab17a62e65f060 (patch)
treefdb76bf2ebc44abe83eaa7274b36c91c03e1428e /src/afl-fuzz.c
parentbfe5b88e782ffd3f97c2a25da60b0b36552a6a64 (diff)
downloadafl++-ab142282a32f93725926d59899ab17a62e65f060.tar.gz
kill targets on exit
Diffstat (limited to 'src/afl-fuzz.c')
-rw-r--r--src/afl-fuzz.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/afl-fuzz.c b/src/afl-fuzz.c
index 46862613..b84585bb 100644
--- a/src/afl-fuzz.c
+++ b/src/afl-fuzz.c
@@ -31,6 +31,23 @@
 extern u64 time_spent_working;
 #endif
 
+static void at_exit() {
+
+  int i;
+  char *ptr = getenv("__AFL_TARGET_PID1");
+
+  if (ptr && *ptr && (i = atoi(ptr)) > 0)
+    kill(i, SIGKILL);
+
+  ptr = getenv("__AFL_TARGET_PID2");
+
+  if (ptr && *ptr && (i = atoi(ptr)) > 0)
+    kill(i, SIGKILL);
+
+  // anything else? shared memory?
+
+}
+
 static u8 *get_libradamsa_path(u8 *own_loc) {
 
   u8 *tmp, *cp, *rsl, *own_copy;
@@ -1242,6 +1259,8 @@ int main(int argc, char **argv_orig, char **envp) {
     OKF("Cmplog forkserver successfully started");
 
   }
+  
+  atexit(at_exit);
 
   perform_dry_run(afl);