refactored global lists

This commit is contained in:
Dominik Maier
2020-04-26 02:32:09 +02:00
parent 85627516a4
commit 66eee34709
6 changed files with 46 additions and 19 deletions

View File

@ -71,7 +71,7 @@ static void init_mopt_globals(afl_state_t *afl) {
/* A global pointer to all instances is needed (for now) for signals to arrive
*/
list_t afl_states = {.element_prealloc_count = 0};
static list_t afl_states = {.element_prealloc_count = 0};
/* Initializes an afl_state_t. */
@ -398,3 +398,34 @@ void afl_state_deinit(afl_state_t *afl) {
}
void afl_states_stop(void) {
/* We may be inside a signal handler.
Set flags first, send kill signals to child proceses later. */
LIST_FOREACH(&afl_states, afl_state_t, {
el->stop_soon = 1;
});
LIST_FOREACH(&afl_states, afl_state_t, {
if (el->fsrv.child_pid > 0) kill(el->fsrv.child_pid, SIGKILL);
if (el->fsrv.fsrv_pid > 0) kill(el->fsrv.fsrv_pid, SIGKILL);
});
}
void afl_states_clear_screen(void) {
LIST_FOREACH(&afl_states, afl_state_t, { el->clear_screen = 1; });
}
void afl_states_request_skip(void) {
LIST_FOREACH(&afl_states, afl_state_t, { el->skip_requested = 1; });
}