<p></p>
<p>How this feature will be used in app_python3 - this gives a hook to call <code>PyOS_AfterFork_Parent</code>:</p>
<pre><code>/**
 *
 */
static pid_t main_pid = 0; /* record pid_t of main process */

static int child_init(int rank)
{
        if(rank==PROC_INIT) {
                /*
                 * this is called before any process is forked
                 * so the Python internal state handler
                 * should be called now.
                 */
#if PY_VERSION_HEX >= 0x03070000
                PyOS_BeforeFork() ;
#endif
                main_pid = getpid();
                return 0;
        }
        if(rank==PROC_POST_FORK) {
                /*
                 * this is called after all processes are forked
                 * so the Python internal state handler
                 * should be called.
                 */
#if PY_VERSION_HEX >= 0x03070000
                PyOS_AfterFork_Parent() ;
#endif
                return 0;
        }
        _apy_process_rank = rank;

        /*
         * If non-daemonize we are called in the main context
         * with rank = PROC_SIPINIT
         */
        if (main_pid != getpid()) {
                /* we really are a child process */
#if PY_VERSION_HEX >= 0x03070000
                PyOS_AfterFork_Child();
#else
                PyOS_AfterFork();
#endif
        }
        if (cfg_child_init()) {
                return -1;
        }
        return apy_init_script(rank);
}
</code></pre>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/kamailio/kamailio/pull/2919#issuecomment-961934666">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ABO7UZP2JGQ77IBWB2CB63LUKPR4XANCNFSM5HNXC72Q">unsubscribe</a>.<br />Triage notifications on the go with GitHub Mobile for <a href="https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675">iOS</a> or <a href="https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub">Android</a>.
<img src="https://github.com/notifications/beacon/ABO7UZKTH42JZKFKY5P23F3UKPR4XA5CNFSM5HNXC722YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOHFK7KSQ.gif" height="1" width="1" alt="" /></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/kamailio/kamailio/pull/2919#issuecomment-961934666",
"url": "https://github.com/kamailio/kamailio/pull/2919#issuecomment-961934666",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>