Reputation: 1367
I was studying the signals topic in python and came across this example
import signal
import os
import time
def receive_signal(signum, stack):
print 'Received:', signum
signal.signal(signal.SIGUSR1, receive_signal)
signal.signal(signal.SIGUSR2, receive_signal)
print 'My PID is:', os.getpid()
while True:
print 'Waiting...'
time.sleep(3)
Now he is sending the signal using this
I ran signal_signal.py in one window, then kill -USR1 $pid, kill -USR2 $pid, and kill -INT $pid in another.
I have few problems
kill -USR1
from where did USR
came from , what parameter is kill command expectingi was thinking kill only kills the process id , why are we passing the parameter to kill command for
Upvotes: 2
Views: 1098
Reputation: 1121614
The kill
command is a little bit misnamed. It sends signals to processes, and the default signal is SIGTERM
, process termination. Using kill
for sending SIGUSR*
signals is perfectly correct.
When you have questions about a UNIX command, your best bet is to type in man <commandname>
on the command line. man kill
would have told you all this and more.
Try running kill -l
for a list of supported signals. You can specify signals by number, by symbolic name and by symbolic name prepended by SIG
. You can use kill -10
, kill -USR1
or kill -SIGUSR1
, all would send the same signal. See the kill
manpage for more details.
Upvotes: 6