@@ -51,6 +51,7 @@ type LPVOID = *mut u8;
5151type JOBOBJECTINFOCLASS = i32 ;
5252type SIZE_T = usize ;
5353type LARGE_INTEGER = i64 ;
54+ type UINT = u32 ;
5455type ULONG_PTR = usize ;
5556type ULONGLONG = u64 ;
5657
@@ -59,6 +60,8 @@ const DUPLICATE_SAME_ACCESS: DWORD = 0x2;
5960const PROCESS_DUP_HANDLE : DWORD = 0x40 ;
6061const JobObjectExtendedLimitInformation : JOBOBJECTINFOCLASS = 9 ;
6162const JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE : DWORD = 0x2000 ;
63+ const SEM_FAILCRITICALERRORS : UINT = 0x0001 ;
64+ const SEM_NOGPFAULTERRORBOX : UINT = 0x0002 ;
6265
6366extern "system" {
6467 fn CreateJobObjectW ( lpJobAttributes : * mut u8 , lpName : * const u8 ) -> HANDLE ;
@@ -79,6 +82,7 @@ extern "system" {
7982 JobObjectInformationClass : JOBOBJECTINFOCLASS ,
8083 lpJobObjectInformation : LPVOID ,
8184 cbJobObjectInformationLength : DWORD ) -> BOOL ;
85+ fn SetErrorMode ( mode : UINT ) -> UINT ;
8286}
8387
8488#[ repr( C ) ]
@@ -115,6 +119,12 @@ struct JOBOBJECT_BASIC_LIMIT_INFORMATION {
115119}
116120
117121pub unsafe fn setup ( ) {
122+ // Tell Windows to not show any UI on errors (such as not finding a required dll
123+ // during startup or terminating abnormally). This is important for running tests,
124+ // since some of them use abnormal termination by design.
125+ // This mode is inherited by all child processes.
126+ SetErrorMode ( SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX ) ;
127+
118128 // Create a new job object for us to use
119129 let job = CreateJobObjectW ( 0 as * mut _ , 0 as * const _ ) ;
120130 assert ! ( job != 0 as * mut _, "{}" , io:: Error :: last_os_error( ) ) ;
0 commit comments