0

I am trying to send the SIGINT signal to multiple processes, I think this is right:

kill -2 <pid1> <pid2> ... <pid3>

but I cannot confirm that...

2

Yes, this is right. The man page confirms it. Running man kill says:

SYNOPSIS
   kill [options] <pid> [...]

...

OPTIONS
   <pid> [...]
          Send signal to every <pid> listed.

Your shell probably provides its own internal version of kill, which will take precedence, but it should be compatible with the interface described. You may be able to find more info by running help kill.

I'd use kill -INT instead of kill -2, since the name-to-number mapping can vary between UNIX variants.

1

This is easy to test with program that generates a bunch of copies of itself, reacts to the signal, and sits around waiting for a signal:

% perl -E '$SIG{INT}=sub {say "ouch"};fork();fork();say $$;sleep 999'
17344
17346
17345
17347
ouch
ouch
ouch
ouch

Kurosawa wipe to the other terminal where a

% kill -2 17344 17346 17345 17347

was obviously run.

1

How about:

for i in <pid1> <pid2> <pid3>; do kill -2 $i; done

Or:

for i in {17344..17347}; do kill -2 $i; done

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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