Skip to content

Commit 01442e7

Browse files
committed
Never close a job after the process is assigned
1 parent acabb52 commit 01442e7

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

src/bootstrap/src/utils/job.rs

+9-13
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,19 @@ mod for_windows {
124124
// (only when wrongly setting the environmental variable),
125125
// it might be better to improve the experience of the second case
126126
// when users have interrupted the parent process and we haven't finish
127-
// duplicating the handle yet. We just need close the job object if that occurs.
128-
CloseHandle(job).ok();
127+
// duplicating the handle yet.
129128
return;
130129
}
131130
};
132131

133132
let mut parent_handle = HANDLE::default();
134-
let r = DuplicateHandle(
133+
// If this fails, well at least we tried! An example of DuplicateHandle
134+
// failing in the past has been when the wrong python2 package spawned this
135+
// build system (e.g., the `python2` package in MSYS instead of
136+
// `mingw-w64-x86_64-python2`). Not sure why it failed, but the "failure
137+
// mode" here is that we only clean everything up when the build system
138+
// dies, not when the python parent does, so not too bad.
139+
let _ = DuplicateHandle(
135140
GetCurrentProcess(),
136141
job,
137142
parent,
@@ -140,15 +145,6 @@ mod for_windows {
140145
false,
141146
DUPLICATE_SAME_ACCESS,
142147
);
143-
144-
// If this failed, well at least we tried! An example of DuplicateHandle
145-
// failing in the past has been when the wrong python2 package spawned this
146-
// build system (e.g., the `python2` package in MSYS instead of
147-
// `mingw-w64-x86_64-python2`). Not sure why it failed, but the "failure
148-
// mode" here is that we only clean everything up when the build system
149-
// dies, not when the python parent does, so not too bad.
150-
if r.is_err() {
151-
CloseHandle(job).ok();
152-
}
148+
CloseHandle(parent).ok();
153149
}
154150
}

0 commit comments

Comments
 (0)