diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc index b7e09c3ad..1c4f1f502 100644 --- a/winsup/cygwin/spawn.cc +++ b/winsup/cygwin/spawn.cc @@ -405,39 +405,35 @@ child_info_spawn::worker (const char *prog_arg, const char *const *argv, c_flags |= CREATE_SEPARATE_WOW_VDM | CREATE_UNICODE_ENVIRONMENT; - if (wincap.has_program_compatibility_assistant ()) + /* We're adding the CREATE_BREAKAWAY_FROM_JOB flag here to workaround + issues with the "Program Compatibility Assistant (PCA) Service". + For some reason, when starting long running sessions from mintty(*), + the affected svchost.exe process takes more and more memory and at one + point takes over the CPU. At this point the machine becomes + unresponsive. The only way to get back to normal is to stop the + entire mintty session, or to stop the PCA service. However, a process + which is controlled by PCA is part of a compatibility job, which + allows child processes to break away from the job. This helps to + avoid this issue. + + First we call IsProcessInJob. It fetches the information whether or + not we're part of a job 20 times faster than QueryInformationJobObject. + + (*) Note that this is not mintty's fault. It has just been observed + with mintty in the first place. See the archives for more info: + http://cygwin.com/ml/cygwin-developers/2012-02/msg00018.html */ + JOBOBJECT_BASIC_LIMIT_INFORMATION jobinfo; + BOOL is_in_job; + + if (IsProcessInJob (GetCurrentProcess (), NULL, &is_in_job) + && is_in_job + && QueryInformationJobObject (NULL, JobObjectBasicLimitInformation, + &jobinfo, sizeof jobinfo, NULL) + && (jobinfo.LimitFlags & (JOB_OBJECT_LIMIT_BREAKAWAY_OK + | JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK))) { - /* We're adding the CREATE_BREAKAWAY_FROM_JOB flag here to workaround - issues with the "Program Compatibility Assistant (PCA) Service" - starting with Windows Vista. For some reason, when starting long - running sessions from mintty(*), the affected svchost.exe process - takes more and more memory and at one point takes over the CPU. At - this point the machine becomes unresponsive. The only way to get - back to normal is to stop the entire mintty session, or to stop the - PCA service. However, a process which is controlled by PCA is part - of a compatibility job, which allows child processes to break away - from the job. This helps to avoid this issue. - - First we call IsProcessInJob. It fetches the information whether or - not we're part of a job 20 times faster than QueryInformationJobObject. - - (*) Note that this is not mintty's fault. It has just been observed - with mintty in the first place. See the archives for more info: - http://cygwin.com/ml/cygwin-developers/2012-02/msg00018.html */ - - JOBOBJECT_BASIC_LIMIT_INFORMATION jobinfo; - BOOL is_in_job; - - if (IsProcessInJob (GetCurrentProcess (), NULL, &is_in_job) - && is_in_job - && QueryInformationJobObject (NULL, JobObjectBasicLimitInformation, - &jobinfo, sizeof jobinfo, NULL) - && (jobinfo.LimitFlags & (JOB_OBJECT_LIMIT_BREAKAWAY_OK - | JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK))) - { - debug_printf ("Add CREATE_BREAKAWAY_FROM_JOB"); - c_flags |= CREATE_BREAKAWAY_FROM_JOB; - } + debug_printf ("Add CREATE_BREAKAWAY_FROM_JOB"); + c_flags |= CREATE_BREAKAWAY_FROM_JOB; } if (mode == _P_DETACH) diff --git a/winsup/cygwin/wincap.cc b/winsup/cygwin/wincap.cc index 5605af628..caa335365 100644 --- a/winsup/cygwin/wincap.cc +++ b/winsup/cygwin/wincap.cc @@ -25,7 +25,6 @@ wincaps wincap_xpsp2 __attribute__((section (".cygwin_dll_common"), shared)) = { has_gaa_largeaddress_bug:false, has_broken_alloc_console:false, has_console_logon_sid:false, - has_program_compatibility_assistant:false, has_pipe_reject_remote_clients:false, terminate_thread_frees_stack:false, has_precise_system_time:false, @@ -46,7 +45,6 @@ wincaps wincap_2003 __attribute__((section (".cygwin_dll_common"), shared)) = { has_gaa_largeaddress_bug:false, has_broken_alloc_console:false, has_console_logon_sid:false, - has_program_compatibility_assistant:false, has_pipe_reject_remote_clients:false, terminate_thread_frees_stack:false, has_precise_system_time:false, @@ -67,7 +65,6 @@ wincaps wincap_vista __attribute__((section (".cygwin_dll_common"), shared)) = { has_gaa_largeaddress_bug:true, has_broken_alloc_console:false, has_console_logon_sid:false, - has_program_compatibility_assistant:true, has_pipe_reject_remote_clients:true, terminate_thread_frees_stack:true, has_precise_system_time:false, @@ -88,7 +85,6 @@ wincaps wincap_7 __attribute__((section (".cygwin_dll_common"), shared)) = { has_gaa_largeaddress_bug:true, has_broken_alloc_console:true, has_console_logon_sid:true, - has_program_compatibility_assistant:true, has_pipe_reject_remote_clients:true, terminate_thread_frees_stack:true, has_precise_system_time:false, @@ -109,7 +105,6 @@ wincaps wincap_8 __attribute__((section (".cygwin_dll_common"), shared)) = { has_gaa_largeaddress_bug:false, has_broken_alloc_console:true, has_console_logon_sid:true, - has_program_compatibility_assistant:true, has_pipe_reject_remote_clients:true, terminate_thread_frees_stack:true, has_precise_system_time:true, @@ -130,7 +125,6 @@ wincaps wincap_10 __attribute__((section (".cygwin_dll_common"), shared)) = { has_gaa_largeaddress_bug:false, has_broken_alloc_console:true, has_console_logon_sid:true, - has_program_compatibility_assistant:true, has_pipe_reject_remote_clients:true, terminate_thread_frees_stack:true, has_precise_system_time:true, @@ -151,7 +145,6 @@ wincaps wincap_10_1511 __attribute__((section (".cygwin_dll_common"), shared)) = has_gaa_largeaddress_bug:false, has_broken_alloc_console:true, has_console_logon_sid:true, - has_program_compatibility_assistant:true, has_pipe_reject_remote_clients:true, terminate_thread_frees_stack:true, has_precise_system_time:true, diff --git a/winsup/cygwin/wincap.h b/winsup/cygwin/wincap.h index 7d7dbc792..d7ba0ec9f 100644 --- a/winsup/cygwin/wincap.h +++ b/winsup/cygwin/wincap.h @@ -18,7 +18,6 @@ struct wincaps unsigned has_gaa_largeaddress_bug : 1; unsigned has_broken_alloc_console : 1; unsigned has_console_logon_sid : 1; - unsigned has_program_compatibility_assistant : 1; unsigned has_pipe_reject_remote_clients : 1; unsigned terminate_thread_frees_stack : 1; unsigned has_precise_system_time : 1; @@ -64,7 +63,6 @@ public: bool IMPLEMENT (has_gaa_largeaddress_bug) bool IMPLEMENT (has_broken_alloc_console) bool IMPLEMENT (has_console_logon_sid) - bool IMPLEMENT (has_program_compatibility_assistant) bool IMPLEMENT (has_pipe_reject_remote_clients) bool IMPLEMENT (terminate_thread_frees_stack) bool IMPLEMENT (has_precise_system_time)