Repository navigation
timeout: return 128 + signal with --preserve-status and --kill-after - #15175
SichenLiang wants to merge 3 commits into
Conversation
|
Please open an issue to track the work. |
|
Opened #15178 for it. |
| if preserve_status { | ||
| let exit_code = status.code().unwrap_or_else(|| { | ||
| platform::status_signal(status).unwrap_or_else(|| { | ||
| let exit_code = status |
There was a problem hiding this comment.
almost the same code as in timeout() below, could be dedup into a small helper, no?
There was a problem hiding this comment.
sure, moved into small preserved_exit_code helper
|
GNU testsuite comparison: |
Merging this PR will degrade performance by 5.74%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ❌ | Simulation | three_39_bit_primes |
498 ms | 591.1 ms | -15.75% |
| ❌ | Simulation | five_38_bit_primes |
1.7 s | 1.8 s | -5.45% |
| ⚡ | Simulation | thirteen_39_bit_primes |
9.8 s | 9.3 s | +5.14% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing SichenLiang:timeout-preserve-status-kill-after (a5abc39) with main (7bc1eb6)
Footnotes
-
54 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
| // This can happen on some platforms or in unusual termination scenarios. | ||
| ExitStatus::TimeoutFailed.into() | ||
| }); | ||
| let exit_code = preserved_exit_code(status).unwrap_or_else(|| { |
There was a problem hiding this comment.
Use unwrap_or instead of unwrap_or_else when the fallback is an inexpensive expression that doesn’t benefit from lazy evaluation.
There was a problem hiding this comment.
Changed it to unwrap_or, thanks!
When --kill-after was set and the command died from the first timeout signal, the preserve-status path returned the bare signal number. SIGTERM, for example, gave status 15 instead of 143. Return 128 + signal here, as timeout already does without --kill-after and as GNU does.
`ExitStatus::TimeoutFailed.into()` is an inexpensive fixed value, so there is no need to build it through an `unwrap_or_else` closure.
a5abc39 to
ccdf89f
Compare
With
--kill-after, if COMMAND died from the first timeout signal before KILL was needed,--preserve-statusreturned the signal number by itself. The path without--kill-afteralready returned 128 + signal, which is also what GNU does.This printed 15 before.
--foreground -s HUPhad the same problem: it returned 1 before and now returns 129.Closes #15178