Commit feafd78
authored
fix(cli): interrupt running commands cleanly on Ctrl+C (#1370)
* fix(cli): interrupt running commands cleanly on Ctrl+C
The launcher (bin/cli.js) spawns the real CLI as a child with inherited
stdio. Previously it was torn down by SIGINT before that child finished,
so the child's final status printed after the shell prompt had already
returned (and the child could be left running in the background).
Wait briefly for the child to handle the interrupt itself and mirror its
exit, so output stays ordered. The wait is bounded: if the child outlives
a short grace period, or on a second Ctrl+C, SIGKILL it and exit with the
conventional 128+signum code. The grace timer is unref'd, so a child that
exits on its own is mirrored with no added latency.
* fix(cli): mirror child signal death as 128+signum, not re-raise
Addresses review feedback: re-raising the child's signal on the launcher
raced against `await spawnPromise` resolving and could leave the default
`process.exitCode` of 1, so Ctrl+C could report exit 1 instead of 130.
Exit explicitly with the conventional 128+signum code (resolved from
os.constants.signals) in the on('exit') signal branch instead.1 parent 5675a51 commit feafd78
1 file changed
Lines changed: 33 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
41 | 68 | | |
42 | 69 | | |
43 | 70 | | |
44 | | - | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
45 | 77 | | |
46 | 78 | | |
47 | 79 | | |
| |||
0 commit comments