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

3 Answers 3

6

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.
    – ZaxLofful
    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

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .