Commit 4572a1d
authored
Shutdown immediately if ctrl+c pressed again (#22593)
# Objective
Prevent the program from hanging if user code that runs on shutdown is
buggy.
## Solution
Update the `TerminalCtrlcHandlerPlugin` to exit immediately if `ctrl-c`
is pressed again.
## Testing
I ran this program and verified that it stopped the second time I
pressed `ctrl-c`.
```rust
use bevy::{app::TerminalCtrlCHandlerPlugin, log::LogPlugin, prelude::*};
fn main() {
App::new()
.add_plugins((TerminalCtrlCHandlerPlugin, LogPlugin::default()))
.add_systems(Update, misbehaving_system)
.run();
}
#[expect(clippy::empty_loop, reason = "testing system that hangs")]
fn misbehaving_system() {
loop {}
}
```
To automate this it needs to be run in a separate process with a
launcher that kills it if it times out. I'm not sure if that is desired
or how that'd fit into bevy's testing setup.1 parent 8f79dbe commit 4572a1d
1 file changed
+14
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
46 | 49 | | |
47 | | - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
48 | 54 | | |
49 | 55 | | |
50 | 56 | | |
51 | 57 | | |
52 | | - | |
53 | | - | |
| 58 | + | |
| 59 | + | |
54 | 60 | | |
55 | 61 | | |
| 62 | + | |
| 63 | + | |
56 | 64 | | |
57 | 65 | | |
58 | 66 | | |
| |||
0 commit comments