Merge branch 'topic/christian/gh-2239-stdin-ctrl-c'

* topic/christian/gh-2239-stdin-ctrl-c:
  Stop signal-masking upon running unit tests
  Pause signal-masking during script parsing
  Add btests to verify Zeek's handling of SIGTERM and reading stdin
  Add procps/procps-ng to several CI Docker images
This commit is contained in:
Christian Kreibich 2022-07-13 11:57:18 -07:00
commit 48486b4156
16 changed files with 159 additions and 3 deletions

View file

@ -606,8 +606,9 @@ SetupResult setup(int argc, char** argv, Options* zopts)
// Mask signals relevant for our signal handlers here. We unmask them
// again further down, when all components that launch threads have done
// so. The launched threads inherit the active signal mask and thus
// prevent our signal handlers from running in unintended threads.
// so, and intermittently during parsing. The launched threads inherit
// the active signal mask and thus prevent our signal handlers from
// running in unintended threads.
set_signal_mask(true);
if ( options.supervisor_mode )
@ -717,6 +718,7 @@ SetupResult setup(int argc, char** argv, Options* zopts)
// Delay the unit test until here so that plugins have been loaded.
if ( options.run_unit_tests )
{
set_signal_mask(false); // Allow ctrl-c to abort the tests early
doctest::Context context;
auto dargs = to_cargs(options.doctest_args);
context.applyCommandLine(dargs.size(), dargs.data());
@ -778,9 +780,15 @@ SetupResult setup(int argc, char** argv, Options* zopts)
if ( options.event_trace_file )
etm = make_unique<EventTraceMgr>(*options.event_trace_file);
// Parsing involves reading input files, including any input
// interactively provided by the user at the console. Temporarily
// undo the signal mask to allow ctrl-c. Ideally we'd do this only
// when we actually end up reading interactively from stdin.
set_signal_mask(false);
run_state::is_parsing = true;
yyparse();
run_state::is_parsing = false;
set_signal_mask(true);
RecordVal::DoneParsing();
TableVal::DoneParsing();