0

When I execute A & B and then cancel with ^C only B gets killed, and A runs on the background. How can I execute A & B as one command I can kill without killing the background job ?

Mehdiway
  • 121
  • 1
    Perhaps you should specify what behavior you want when you say "execute A & B as 'one command.'" Do you mean you want them to execute sequentially rather than concurrently? To have the same PID (which is impossible)? To have one be a child of the other? To have one die when the other is killed? "One command" is quite vague; A and B are separate simple commands however you connect them (whether in a pipeline, a list, a compound command, or other method.) – Wildcard Dec 12 '16 at 01:45
  • from http://unix.stackexchange.com/questions/204480/run-multiple-commands-and-kill-them-as-one-in-bash ~$ trap 'kill %1; kill %2' SIGINT; ~$ command1 & command2 & command3 – mrwhale Dec 12 '16 at 01:47
  • They should run both simultanuously. And one has to die when the other is killed – Mehdiway Dec 12 '16 at 01:48

1 Answers1

2

The solution : Run it as (A & B) with parentheses

Mehdiway
  • 121