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 ?

closed as unclear what you're asking by Wildcard, HalosGhost, techraf, Satō Katsura, Anthon Dec 12 '16 at 7:21

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 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 1:45
  • from unix.stackexchange.com/questions/204480/… ~$ trap 'kill %1; kill %2' SIGINT; ~$ command1 & command2 & command3 – mrwhale Dec 12 '16 at 1:47
  • They should run both simultanuously. And one has to die when the other is killed – Mehdiway Dec 12 '16 at 1:48

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.