test: Fix flaky test_daemon_sigint #7888
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The test is supposed to verify the correct and clean shutdown when osquery receives a SIGINT.
The clean shutdown though, is only possible when the signal handler is installed, which might not happen immediately,
so there might be a window where if the test sends a SIGINT it will immediately interrupt the osquery process with exit code -2, due to the signal, making the test fail.
Originally the test was waiting for the pidfile to be created by the process, because at that point the signal handler was installed. But a regression was introduced and the pidfile path was created by the test itself before starting osquery,
causing the wait to not work properly.
This restores that logic by removing the creation of that path in the test.
We also ensure that there's no pidfile created by another test.
Fixes #7718