about summary refs log tree commit diff
path: root/src/afl-fuzz.c
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2020-11-19 16:14:19 +0100
committervan Hauser <vh@thc.org>2020-11-19 16:14:19 +0100
commite32b7eeb83c0571a2bdaadfd5b7b769fec1405cc (patch)
tree474d91fe4f69f650f5604f7c417b8bdc0654169e /src/afl-fuzz.c
parentcd0a25be5e9b05a2ab6a11592cd95e7f653bf42d (diff)
downloadafl++-e32b7eeb83c0571a2bdaadfd5b7b769fec1405cc.tar.gz
fixed child not killed with -c
Diffstat (limited to 'src/afl-fuzz.c')
-rw-r--r--src/afl-fuzz.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/afl-fuzz.c b/src/afl-fuzz.c
index 1008f28c..b60908da 100644
--- a/src/afl-fuzz.c
+++ b/src/afl-fuzz.c
@@ -40,7 +40,7 @@ extern u64 time_spent_working;
 
 static void at_exit() {
 
-  int   i;
+  s32   i, pid1 = 0, pid2 = 0;
   char *list[4] = {SHM_ENV_VAR, SHM_FUZZ_ENV_VAR, CMPLOG_SHM_ENV_VAR, NULL};
   char *ptr;
 
@@ -48,10 +48,10 @@ static void at_exit() {
   if (ptr && *ptr) unlink(ptr);
 
   ptr = getenv("__AFL_TARGET_PID1");
-  if (ptr && *ptr && (i = atoi(ptr)) > 0) kill(i, SIGKILL);
+  if (ptr && *ptr && (pid1 = atoi(ptr)) > 0) kill(pid1, SIGTERM);
 
   ptr = getenv("__AFL_TARGET_PID2");
-  if (ptr && *ptr && (i = atoi(ptr)) > 0) kill(i, SIGKILL);
+  if (ptr && *ptr && (pid2 = atoi(ptr)) > 0) kill(pid2, SIGTERM);
 
   i = 0;
   while (list[i] != NULL) {
@@ -75,6 +75,9 @@ static void at_exit() {
 
   }
 
+  if (pid1 > 0) { kill(pid1, SIGKILL); }
+  if (pid2 > 0) { kill(pid2, SIGKILL); }
+
 }
 
 /* Display usage hints. */