From: Anatol Belski Date: Mon, 18 Jan 2016 19:52:17 +0000 (+0100) Subject: trap also children exits on shutdown to avoid unhandled exceptions X-Git-Tag: php-7.2.0alpha1~620^2~110 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8e60e0c927be64d455f3740150da385d23df07af;p=php trap also children exits on shutdown to avoid unhandled exceptions --- diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c index d9d6e76a8d..d18ed21d7a 100644 --- a/sapi/cgi/cgi_main.c +++ b/sapi/cgi/cgi_main.c @@ -226,6 +226,8 @@ static php_cgi_globals_struct php_cgi_globals; #define WIN32_MAX_SPAWN_CHILDREN 64 HANDLE win32_kid_cgi_ps[WIN32_MAX_SPAWN_CHILDREN]; int win32_kids; +HANDLE win32_job; +JOBOBJECT_EXTENDED_LIMIT_INFORMATION win32_ji = { 0 }; #endif #ifndef HAVE_ATTRIBUTE_WEAK @@ -2119,6 +2121,10 @@ consult the installation file that came with this distribution, or visit \n\ GetModuleFileName(NULL, my_name, MAX_PATH); cmd_line = my_name; + win32_job = CreateJobObject(NULL, NULL); + win32_ji.BasicLimitInformation.LimitFlags = JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE; + SetInformationJobObject(win32_job, JobObjectExtendedLimitInformation, &win32_ji, sizeof(win32_ji)); + while (parent) { i = win32_kids; while (0 < i--) { @@ -2152,6 +2158,7 @@ consult the installation file that came with this distribution, or visit \n\ if (CreateProcess(NULL, cmd_line, NULL, NULL, TRUE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi)) { win32_kid_cgi_ps[i] = pi.hProcess; + AssignProcessToJobObject(win32_job, pi.hProcess); CloseHandle(pi.hThread); } else { DWORD err = GetLastError();