Skip to content

Commit

Permalink
Use terminate_process() when stopping scans.
Browse files Browse the repository at this point in the history
  • Loading branch information
kroosec committed May 15, 2019
1 parent 93b95d7 commit 7d0eaa5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/attack.c
Original file line number Diff line number Diff line change
Expand Up @@ -959,7 +959,7 @@ check_kb_access (int soc)
static void
handle_scan_stop_signal ()
{
pluginlaunch_stop (0);
pluginlaunch_stop ();
global_scan_stop = 1;
}

Expand Down
14 changes: 2 additions & 12 deletions src/pluginlaunch.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,25 +297,15 @@ pluginlaunch_enable_parallel_checks (void)
}

void
pluginlaunch_stop (int soft_stop)
pluginlaunch_stop ()
{
int i;

if (soft_stop)
{
for (i = 0; i < MAX_PROCESSES; i++)
{
if (processes[i].pid > 0)
kill (processes[i].pid, SIGTERM);
}
usleep (20000);
}

for (i = 0; i < MAX_PROCESSES; i++)
{
if (processes[i].pid > 0)
{
kill (processes[i].pid, SIGKILL);
terminate_process (processes[i].pid * -1);
num_running_processes--;
processes[i].plugin->running_state = PLUGIN_STATUS_DONE;
bzero (&(processes[i]), sizeof (struct running));
Expand Down
4 changes: 3 additions & 1 deletion src/pluginlaunch.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ void
pluginlaunch_init (const char *);
void pluginlaunch_wait (kb_t);
void pluginlaunch_wait_for_free_process (kb_t);

void
pluginlaunch_stop (int);
pluginlaunch_stop ();

int
plugin_launch (struct scan_globals *, struct scheduler_plugin *,
struct in6_addr *, GSList *, kb_t, nvti_t *);
Expand Down

0 comments on commit 7d0eaa5

Please sign in to comment.