com php-src: trap also children exits on shutdown to avoid unhandled exceptions: sapi/cgi/cgi_main.c

From: Date: Mon, 18 Jan 2016 19:52:17 +0000
Subject: com php-src: trap also children exits on shutdown to avoid unhandled exceptions: sapi/cgi/cgi_main.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-90691@lists.php.net to get a copy of this message
Commit: 8e60e0c927be64d455f3740150da385d23df07af Author: Anatol Belski <ab@php.net> Mon, 18 Jan 2016 20:52:17 +0100 Parents: 5e73db9cb71dad5084e44a945e9370ccd1e7d494 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=8e60e0c927be64d455f3740150da385d23df07af Log: trap also children exits on shutdown to avoid unhandled exceptions Changed paths: M sapi/cgi/cgi_main.c Diff: diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c index d9d6e76..d18ed21 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();

« previous php.cvs (#90691) next »