Skip to content

Commit

Permalink
Fix: process handler deadlock and signal handler
Browse files Browse the repository at this point in the history
The PR #1165 contained two major errors. A lock to prevent a deadlock and handling signals in case the module is not initialized
  • Loading branch information
Kraemii committed Aug 22, 2022
1 parent c72b6df commit c9b9e8d
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/processes.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ procs_init (int max)
num_procs = 0;
openvas_signal (SIGCHLD, clear_child);
openvas_signal (SIGTERM, terminate);
openvas_signal (SIGINT, terminate);
openvas_signal (SIGQUIT, terminate);
initialized = 1;
}

Expand All @@ -212,6 +214,9 @@ init_child_signal_handlers (void)
{
/* SIGHUP is only for reloading main scanner process. */
openvas_signal (SIGHUP, SIG_IGN);
openvas_signal (SIGTERM, make_em_die);
openvas_signal (SIGINT, make_em_die);
openvas_signal (SIGQUIT, make_em_die);
openvas_signal (SIGSEGV, sighand_segv);
openvas_signal (SIGPIPE, SIG_IGN);
}
Expand All @@ -236,7 +241,9 @@ create_process (process_func_t func, void *args)
while (!procs[++pos].terminated)
;
}
gvm_log_lock ();
pid_t pid = fork ();
gvm_log_unlock ();
if (!pid)
{
initialized = 0;
Expand Down

0 comments on commit c9b9e8d

Please sign in to comment.