@@ -42,9 +42,9 @@ pub unsafe fn setup(build: &mut crate::Build) {
42
42
#[ cfg( windows) ]
43
43
mod for_windows {
44
44
use std:: ffi:: c_void;
45
- use std:: { env , io, mem} ;
45
+ use std:: { io, mem} ;
46
46
47
- use windows:: Win32 :: Foundation :: { CloseHandle , DUPLICATE_SAME_ACCESS , DuplicateHandle , HANDLE } ;
47
+ use windows:: Win32 :: Foundation :: CloseHandle ;
48
48
use windows:: Win32 :: System :: Diagnostics :: Debug :: {
49
49
SEM_NOGPFAULTERRORBOX , SetErrorMode , THREAD_ERROR_MODE ,
50
50
} ;
@@ -53,9 +53,7 @@ mod for_windows {
53
53
JOB_OBJECT_LIMIT_PRIORITY_CLASS , JOBOBJECT_EXTENDED_LIMIT_INFORMATION ,
54
54
JobObjectExtendedLimitInformation , SetInformationJobObject ,
55
55
} ;
56
- use windows:: Win32 :: System :: Threading :: {
57
- BELOW_NORMAL_PRIORITY_CLASS , GetCurrentProcess , OpenProcess , PROCESS_DUP_HANDLE ,
58
- } ;
56
+ use windows:: Win32 :: System :: Threading :: { BELOW_NORMAL_PRIORITY_CLASS , GetCurrentProcess } ;
59
57
use windows:: core:: PCWSTR ;
60
58
61
59
use crate :: Build ;
@@ -95,49 +93,8 @@ mod for_windows {
95
93
return ;
96
94
}
97
95
98
- // If we've got a parent process (e.g., the python script that called us)
99
- // then move ownership of this job object up to them. That way if the python
100
- // script is killed (e.g., via ctrl-c) then we'll all be torn down.
101
- //
102
- // If we don't have a parent (e.g., this was run directly) then we
103
- // intentionally leak the job object handle. When our process exits
96
+ // Note: we intentionally leak the job object handle. When our process exits
104
97
// (normally or abnormally) it will close the handle implicitly, causing all
105
98
// processes in the job to be cleaned up.
106
- let pid = match env:: var ( "BOOTSTRAP_PARENT_ID" ) {
107
- Ok ( s) => s,
108
- Err ( ..) => return ,
109
- } ;
110
-
111
- let parent = match OpenProcess ( PROCESS_DUP_HANDLE , false , pid. parse ( ) . unwrap ( ) ) . ok ( ) {
112
- Some ( parent) => parent,
113
- _ => {
114
- // If we get a null parent pointer here, it is possible that either
115
- // we have an invalid pid or the parent process has been closed.
116
- // Since the first case rarely happens
117
- // (only when wrongly setting the environmental variable),
118
- // it might be better to improve the experience of the second case
119
- // when users have interrupted the parent process and we haven't finish
120
- // duplicating the handle yet.
121
- return ;
122
- }
123
- } ;
124
-
125
- let mut parent_handle = HANDLE :: default ( ) ;
126
- // If this fails, well at least we tried! An example of DuplicateHandle
127
- // failing in the past has been when the wrong python2 package spawned this
128
- // build system (e.g., the `python2` package in MSYS instead of
129
- // `mingw-w64-x86_64-python2`). Not sure why it failed, but the "failure
130
- // mode" here is that we only clean everything up when the build system
131
- // dies, not when the python parent does, so not too bad.
132
- let _ = DuplicateHandle (
133
- GetCurrentProcess ( ) ,
134
- job,
135
- parent,
136
- & mut parent_handle,
137
- 0 ,
138
- false ,
139
- DUPLICATE_SAME_ACCESS ,
140
- ) ;
141
- CloseHandle ( parent) . ok ( ) ;
142
99
}
143
100
}
0 commit comments