Configurable wait timeout for process to end and `-w SECONDS` CLI option
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**
* Added a `-w SECONDS` command-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 (`86400` seconds). [[1]](diffhunk://#diff-a0cb465674c1b01a07d361f25a0ef2b0214b7dfe9412b7777f89add956da10ecL179-R184) [[2]](diffhunk://#diff-a0cb465674c1b01a07d361f25a0ef2b0214b7dfe9412b7777f89add956da10ecR282-R291) [[3]](diffhunk://#diff-a0cb465674c1b01a07d361f25a0ef2b0214b7dfe9412b7777f89add956da10ecR342)
* Updated the `poll_loop_args_t` struct and related logic to store and use the new `kill_wait_timeout_secs` value, defaulting to 10 seconds. [[1]](diffhunk://#diff-1713f949b66c0ce86f50a3021b07dd22ede1812572b989cf9d91ed9d143ef82aR36-R37) [[2]](diffhunk://#diff-a0cb465674c1b01a07d361f25a0ef2b0214b7dfe9412b7777f89add956da10ecR148)
* Modified the process waiting logic in `kill_wait` to use the user-specified timeout, with overflow protection for the poll loop. [[1]](diffhunk://#diff-0bc65e62b22f542a4d4a54ff38bc3238ec54565b476faceec08b5db98e8cc590L264-R278) [[2]](diffhunk://#diff-0bc65e62b22f542a4d4a54ff38bc3238ec54565b476faceec08b5db98e8cc590L306-R316)
**Documentation and testing**
* Updated the documentation (`MANPAGE.md`) to describe the new `-w` option and its usage.
* Added and updated CLI tests to verify correct handling of the `-w` flag, including invalid values and edge cases.
**Internal constants and options**
* Introduced a new constant for the maximum allowed wait timeout and updated the CLI options enum accordingly. [[1]](diffhunk://#diff-a0cb465674c1b01a07d361f25a0ef2b0214b7dfe9412b7777f89add956da10ecR36-R38) [[2]](diffhunk://#diff-a0cb465674c1b01a07d361f25a0ef2b0214b7dfe9412b7777f89add956da10ecR49)
合并状态:未合并 关闭于 2026-02-18 8 条评论