2023-03-15 01:00:08 +00:00
|
|
|
from signal import pthread_kill
|
|
|
|
from signal import signal as sigsignal
|
2023-03-13 01:35:54 +00:00
|
|
|
|
|
|
|
class SignalRouter:
|
|
|
|
def __init__(self):
|
2023-03-15 01:00:08 +00:00
|
|
|
self.signal_thread_dictionary = {}
|
|
|
|
|
2023-03-16 01:47:25 +00:00
|
|
|
def __route_signal(self, signal, frame):
|
|
|
|
pthread_kill(self.signal_thread_dictionary[signal], signal)
|
|
|
|
|
2023-03-15 01:00:08 +00:00
|
|
|
def register_signal_thread(self, signal, thread_ident):
|
|
|
|
self.signal_thread_dictionary[signal] = thread_ident
|
|
|
|
sigsignal(signal, self.__route_signal)
|