[SR-Users] Kill child process created by app_python module

Marat Gareev maratkin94 at gmail.com
Tue Sep 13 19:15:13 CEST 2022


Hello!

I'm trying to use app_python module to perform periodic actions.

This is a simple python code
def _update():
while True:
_action()
time.sleep(60)

class noop_handler:
def child_init(self, rank):
return 0

def ksr_request_route(self, msg):
return 1

def mod_init():
# signal.signal(signal.SIGTERM, signal.default_int_handler)
proc = multiprocessing.Process(target=_update)
# proc.daemon = True
proc.start()
ksr.notice('Forked process {} to update\n'.format(proc.pid))
return noop_handler()

After killing kamailio processes with SIGTERM signal (killall kamailio) I
see zombie process.
And if I try to process the signal in daemon mode (see the comments in the
snippet above), I get critical errors in the logs and still see processes:
0(37001) NOTICE: <core> [core/kemi.c:124]: sr_kemi_core_notice(): Forked
process 37002 to update
1(37003) ERROR: <core> [core/udp_server.c:464]: udp_rcv_loop(): recvfrom:[4]
Interrupted system call
Process Process-1:
Traceback (most recent call last):
File "/usr/lib64/python2.7/multiprocessing/process.py", line 258, in
_bootstrap
self.run()
File "/usr/lib64/python2.7/multiprocessing/process.py", line 114, in run
self._target(*self._args, **self._kwargs)
File "/tmp/script.py", line 155, in _update
time.sleep(period)
KeyboardInterrupt
0(37001) ALERT: <core> [main.c:774]: handle_sigs(): child process 37002
exited normally, status=1
0(37001) INFO: <core> [main.c:802]: handle_sigs(): terminating due to
SIGCHLD
1(37003) ERROR: <core> [core/udp_server.c:464]: udp_rcv_loop(): recvfrom:[4]
Interrupted system call
8(37014) CRITICAL: <core> [core/pass_fd.c:277]: receive_fd(): EOF on 4
1(37003) ERROR: <core> [core/udp_server.c:464]: udp_rcv_loop(): recvfrom:[4]
Interrupted system call

So, how I can kill child process by SIGTERM signal?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20220913/d8d4199d/attachment.htm>


More information about the sr-users mailing list