@@ -51,6 +51,7 @@ type LPVOID = *mut u8;
51
51
type JOBOBJECTINFOCLASS = i32 ;
52
52
type SIZE_T = usize ;
53
53
type LARGE_INTEGER = i64 ;
54
+ type UINT = u32 ;
54
55
type ULONG_PTR = usize ;
55
56
type ULONGLONG = u64 ;
56
57
@@ -59,6 +60,8 @@ const DUPLICATE_SAME_ACCESS: DWORD = 0x2;
59
60
const PROCESS_DUP_HANDLE : DWORD = 0x40 ;
60
61
const JobObjectExtendedLimitInformation : JOBOBJECTINFOCLASS = 9 ;
61
62
const JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE : DWORD = 0x2000 ;
63
+ const SEM_FAILCRITICALERRORS : UINT = 0x0001 ;
64
+ const SEM_NOGPFAULTERRORBOX : UINT = 0x0002 ;
62
65
63
66
extern "system" {
64
67
fn CreateJobObjectW ( lpJobAttributes : * mut u8 , lpName : * const u8 ) -> HANDLE ;
@@ -79,6 +82,7 @@ extern "system" {
79
82
JobObjectInformationClass : JOBOBJECTINFOCLASS ,
80
83
lpJobObjectInformation : LPVOID ,
81
84
cbJobObjectInformationLength : DWORD ) -> BOOL ;
85
+ fn SetErrorMode ( mode : UINT ) -> UINT ;
82
86
}
83
87
84
88
#[ repr( C ) ]
@@ -115,6 +119,12 @@ struct JOBOBJECT_BASIC_LIMIT_INFORMATION {
115
119
}
116
120
117
121
pub 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
+
118
128
// Create a new job object for us to use
119
129
let job = CreateJobObjectW ( 0 as * mut _ , 0 as * const _ ) ;
120
130
assert ! ( job != 0 as * mut _, "{}" , io:: Error :: last_os_error( ) ) ;
0 commit comments