open-cli-tools / concurrently

Run commands concurrently. Like `npm run watch-js & npm run watch-less` but better.
https://www.npmjs.com/package/concurrently
MIT License
6.98k stars 227 forks source link

Cancel a series of tasks with SIGINT #452

Closed bozdoz closed 5 months ago

bozdoz commented 9 months ago

Description:

I want to run a series of tasks, that are cancellable.

Expected Behaviour:

If I press CTRL-C, I want the entire script (each of the series of tasks) to be aborted (or not started).

Actual Behaviour:

I need to press CTRL-C multiple times to cancel each process.

Reproduction:

Note the -m 1 flag to run one process consecutively.

{
"sleep": "concurrently --kill-others-on-fail -m 1 \"sleep 3\" \"echo 'hi'\" \"sleep 3\" \"echo 'there'\" \"sleep 3\" \"echo 'buddy'\""
}
npm run sleep

> concurrently --kill-others-on-fail -m 1 "sleep 3" "echo 'hi'" "sleep 3" "echo 'there'" "sleep 3" "echo 'buddy'"

^C[0] sleep 3 exited with code SIGINT
[1] hi
[1] echo 'hi' exited with code 0
[2] sleep 3 exited with code 0
[3] there
[3] echo 'there' exited with code 0
[4] sleep 3 exited with code 0
[5] buddy
[5] echo 'buddy' exited with code 0

Is this a bug, or is there a way to do this that is not obvious?

gustavohenke commented 9 months ago

Duplicate of #433

I think it's more of a bug.

gustavohenke commented 9 months ago

Sorry, I was a bit hasty marking this as a duplicate of #433. Signals such as SIGINT received by the main process work separately from --kill-others-on-fail.

bozdoz commented 9 months ago

So would this be a feature request? A bug? User error?

gustavohenke commented 9 months ago

It's a bug. Just tagged it as such

SrBrahma commented 8 months ago

Up.

"dev": "concurrently -c blue,green -n tsw,next \"bun tsw\" \"next dev\""

I already tried all the combinations of the --kill options but they won't work. I have to press Ctrl+C twice to kill all.