1

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
  • How could you test it? Commented Sep 14, 2018 at 19:16
  • that is a damn good question lulz Commented Sep 16, 2018 at 6:03

3 Answers 3

7

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
  • Thanks! This fixed my issue with my game server not saving, because it needed SIGINT instead of KILL and the number mapping was failing. Commented Mar 23, 2022 at 7:20
2

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
0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.