Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

do not sleep to kill a process that has already cleaned up and exited by itself #672

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

istyf
Copy link

@istyf istyf commented Nov 1, 2024

This PR fixes #671 by replacing the time.Sleep in killCmd (for linux and unix/mac) with a cancelable context that can be used to stop the kill timer and return to the caller as soon as the interrupted process has closed down.

While developing this PR I took the liberty of deleting the unit test for testing killing of "non existing" processes for reasons outlined in 52428bf.

This PR has been tested on wsl2 linux and an Apple M2 MBP.

if the process to be killed honours the SIGINT and closes down,
we should not sleep before trying to kill a process that is
no longer there
the test paniced if it ever got a nil err since t.Failf does not
imply that test is stopped

selecting a random pid to kill might have interesting side effects
when run and its result can never be guaranteed to be the same, meaning
that the test had intermittent failures

no code depends on the specific return code of killCmd, so there
does not seem to be a reason to have a unit test for it
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Do not sleep the full kill_delay when using send_interrupt and the current application shuts down by itself
1 participant