Module: kamailio
Branch: 4.4
Commit: 78684f2bba3d408e60eb8450bf915ebe92c8f8d1
URL: 
https://github.com/kamailio/kamailio/commit/78684f2bba3d408e60eb8450bf915ebe92c8f8d1

Author: codyherzog <cher...@intouchhealth.com>
Committer: Daniel-Constantin Mierla <mico...@gmail.com>
Date: 2017-08-08T14:16:15+02:00

core: Don't terminate on harmless SIGCHLD.

If it appears that no child process has stopped, then do not terminate
on SIGCHLD. Certain modules like app_python can run external scripts
which cause child processes to be started and stopped. That can result
in SIGCHLD being received even though there is no real problem.
Therefore, we do not terminate Kamailio unless we can find the child
process which has stopped.

(cherry picked from commit 1c5e166001306a1a9d9d8412f0a54910093109cb)
(cherry picked from commit f508665fdbfe63cd03989dca067e6c725c8344d0)

---

Modified: main.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/78684f2bba3d408e60eb8450bf915ebe92c8f8d1.diff
Patch: 
https://github.com/kamailio/kamailio/commit/78684f2bba3d408e60eb8450bf915ebe92c8f8d1.patch

---

diff --git a/main.c b/main.c
index b6f68df1a4..2b739ac805 100644
--- a/main.c
+++ b/main.c
@@ -675,6 +675,7 @@ void handle_sigs(void)
 {
        pid_t   chld;
        int     chld_status;
+       int     any_chld_stopped;
        int memlog;
 
        switch(sig_flag){
@@ -730,7 +731,9 @@ void handle_sigs(void)
                        break;
 
                case SIGCHLD:
+                       any_chld_stopped=0;
                        while ((chld=waitpid( -1, &chld_status, WNOHANG ))>0) {
+                               any_chld_stopped=1;
                                if (WIFEXITED(chld_status))
                                        LM_ALERT("child process %ld exited 
normally,"
                                                        " status=%d\n", 
(long)chld,
@@ -747,6 +750,16 @@ void handle_sigs(void)
                                                                " signal %d\n", 
(long)chld,
                                                                 
WSTOPSIG(chld_status));
                        }
+
+                       /* If it appears that no child process has stopped, 
then do not terminate on SIGCHLD.
+                          Certain modules like app_python can run external 
scripts which cause child processes to be started and
+                          stopped. That can result in SIGCHLD being received 
here even though there is no real problem. Therefore,
+                          we do not terminate Kamailio unless we can find the 
child process which has stopped. */
+                       if (!any_chld_stopped) {
+                               LM_INFO("SIGCHLD received, but no child has 
stopped, ignoring it\n");
+                               break;
+                       }
+
 #ifndef STOP_JIRIS_CHANGES
                        if (dont_fork) {
                                LM_INFO("dont_fork turned on, living on\n");


_______________________________________________
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to