Configurable wait timeout for process to end and -w SECONDS CLI option#363
Configurable wait timeout for process to end and -w SECONDS CLI option#363iandennismiller wants to merge 20 commits intorfjakob:masterfrom
-w SECONDS CLI option#363Conversation
Co-authored-by: iandennismiller <90502+iandennismiller@users.noreply.github.com>
…afety Co-authored-by: iandennismiller <90502+iandennismiller@users.noreply.github.com>
Co-authored-by: iandennismiller <90502+iandennismiller@users.noreply.github.com>
Co-authored-by: iandennismiller <90502+iandennismiller@users.noreply.github.com>
Co-authored-by: iandennismiller <90502+iandennismiller@users.noreply.github.com>
Co-authored-by: iandennismiller <90502+iandennismiller@users.noreply.github.com>
…wait-countdown Add configurable kill_wait() timeout via -w flag
|
Hi, what problem does this solve? |
|
The process I'm monitoring takes longer than 10 seconds to shut down; and if it is terminated forcefully, it results in database corruption. I need to prevent earlyoom from re-issuing SIGTERM every 10 seconds. Eventually, sending enough SIGTERMs will cause the process to terminate early, which corrupts the database. So, after 100 seconds and the receipt of 10 SIGTERMs, it will exit immediately as if it were SIGKILLed. With the flag in this PR, I am specifying |
|
So your process counts SIGTERMs? What process is this? |
|
go-ethereum |
Exactly; a bit idiosyncratic but there are non-production situations where it's handy, I suppose. But for my purposes, I need to work around the 10 SIGTERMS behavior because it's not what I intend. |
rfjakob
left a comment
There was a problem hiding this comment.
Some small changes, otherwise ok.
|
|
||
| int c; | ||
| const char* short_opt = "m:s:M:S:kingN:P:dvr:ph"; | ||
| const char* short_opt = "m:s:M:S:kingN:P:dvr:phw:"; |
There was a problem hiding this comment.
Please make this --kill-wait instead of -w.
| " to 0 to disable completely\n" | ||
| " -p set niceness of earlyoom to -20 and oom_score_adj to\n" | ||
| " -100\n" | ||
| " -w SECONDS max seconds to wait for a process to die (default 10)\n" |
| OOMScoreAdjust=-100 | ||
| Nice=-20 | ||
|
|
||
| #### -w SECONDS |
kill.c
Outdated
| if ((unsigned)args->kill_wait_timeout_secs > UINT_MAX / 10u) { | ||
| // Cap at maximum to avoid overflow (should never happen in practice) | ||
| max_poll_iterations = UINT_MAX; |
There was a problem hiding this comment.
Cannot happen. Delete the check.
Currently fails with Minimum supported API version is 1.44, please upgrade your client to a newer version. addnab/docker-run-action#62
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2 to 4. - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](github/codeql-action@v2...v4) --- updated-dependencies: - dependency-name: github/codeql-action dependency-version: '4' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com>
Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 6. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](actions/checkout@v2...v6) --- updated-dependencies: - dependency-name: actions/checkout dependency-version: '6' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com>
As mentioned in issue rfjakob/earlyoom#358 and README, after Linux 5.17, OOM sysrq will always kill a process. This implements an option for trigger the kernel oom killer i.e. write an `f` to `/proc/sysrq-trigger`. Since the victim cannot be chosen by earlyoom, some of the features about customized victim selection won't take effect.
Co-authored-by: iandennismiller <90502+iandennismiller@users.noreply.github.com>
Co-authored-by: iandennismiller <90502+iandennismiller@users.noreply.github.com>
Co-authored-by: iandennismiller <90502+iandennismiller@users.noreply.github.com>
|
I am going to change the sequencing of this pull request and re-submit a new one in a bit. The problem is that I merged to master and based the PR on that, when I should have based the PR on the pre-merge branch. It will be simpler for me to cherry-pick the changes into a new branch that's already synced to yours. |
|
Closing this PR. Please see #366 for the replacement PR with a cleaner merge path. |
This pull request introduces a new configurable option,
-w SECONDS, to control the maximum time earlyoom waits for a killed process to exit. The implementation includes updates to the CLI, input validation, documentation, and associated tests. This change allows users to adjust the wait timeout (default 10 seconds) to better handle processes that take longer to terminate.New feature: Configurable process wait timeout
-w SECONDScommand-line option to set the maximum wait time (in seconds) for a killed process to exit, with input validation and a maximum limit of 24 hours (86400seconds). [1] [2] [3]poll_loop_args_tstruct and related logic to store and use the newkill_wait_timeout_secsvalue, defaulting to 10 seconds. [1] [2]kill_waitto use the user-specified timeout, with overflow protection for the poll loop. [1] [2]Documentation and testing
MANPAGE.md) to describe the new-woption and its usage.-wflag, including invalid values and edge cases.Internal constants and options