zx icon indicating copy to clipboard operation
zx copied to clipboard

kill() should only resolve when the process exits

Open gajus opened this issue 2 years ago • 2 comments

Expected Behavior

kill().then(() => { console.log('expect this to be called only when process exist'); })

Actual Behavior

kill().then(() => { console.log('not clear when this is called, but the process is still up'); })

Specifications

  • Version: v7.2.1
  • Platform: macOS

gajus avatar Jun 05 '23 20:06 gajus

Something like this https://github.com/gajus/turbowatch/commit/f9966be788c21c60fb7d12af6c1543e0724449a9

gajus avatar Jun 05 '23 20:06 gajus

Up to date implementation is here https://github.com/gajus/turbowatch/blob/main/src/killPsTree.ts

gajus avatar Jun 06 '23 15:06 gajus

The current impl just emits resolved when all associated processes have received the signal. Perhaps, sometimes we should wait for all these signals to be processed, but status polling via cp.spawn requires configurable timings, debounces, etc. I suggest providing this externally if necessary: $.kill = async () => {}

antongolub avatar Mar 26 '24 22:03 antongolub