How can I send a signal from a python program?

前端 未结 2 1049
眼角桃花
眼角桃花 2020-12-05 13:45

I have this code which listens to USR1 signals

import signal
import os
import time

def receive_signal(signum, stack):
    print \'Received:\', signum

signa         


        
2条回答
  •  感情败类
    2020-12-05 14:26

    You can use os.kill():

    os.kill(os.getpid(), signal.SIGUSR1)
    

    Put this anywhere in your code that you want to send the signal from.

提交回复
热议问题