Skip to content

Commit

Permalink
Loop and wait for multiple terminted processes.
Browse files Browse the repository at this point in the history
If you have a bunch of exec() calls (translated into a bunch of additional processes created), upon their termiantion OpenSIPS will get a cascade of SIGCHLD signals - as the kernel does not guarantee the delivery of the signals (like mergining similar multiple signal triggers), we will not have a 1-to-1 between terminated processes and received signals.
So, let's do our best and upon a single SIGCHLD we will try to "catch" as many terminated processes as possible/available.

Closes #1773

(cherry picked from commit 57f3619)
  • Loading branch information
bogdan-iancu committed Sep 27, 2019
1 parent 698f132 commit 9fa9615
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions main.c
Expand Up @@ -684,9 +684,9 @@ static void sig_usr(int signo)
exit(0);
break;
case SIGCHLD:
pid = waitpid(-1, &status, WNOHANG);
LM_DBG("SIGCHLD received from %ld (status=%d), ignoring\n",
(long)pid,status);
while ( (pid = waitpid(-1, &status, WNOHANG))>0 )
LM_DBG("SIGCHLD received from %ld (status=%d),"
" ignoring\n", (long)pid,status);
break;
case SIGSEGV:
/* looks like we ate some spicy SIP */
Expand Down

0 comments on commit 9fa9615

Please sign in to comment.