As a note here, there are a lot of resources that make bash seem incredibly arcane, with custom functions often recommended. But a simple interruptible script to run things in parallel can be as simple as:
(trap 'kill 0' INT TERM; cmd1 & cmd2 & cmd3 & wait)
Or, for 1+2 sequentially, in parallel with 3+4 sequentially: (trap 'kill 0' INT TERM;
(cmd1 && cmd2) &
(cmd3 && cmd4) &
wait
)
(To oversimplify: The trap propagates the signal (with 'kill') to the process group 0 made by the () parens; this only needs to be set at the top level. & means run in background, && means run and continue only on success.)There are other reasons one might not want to depend on bash, but it's not something to be afraid of!