File tree Expand file tree Collapse file tree 1 file changed +14
-6
lines changed Expand file tree Collapse file tree 1 file changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -103,12 +103,20 @@ pub unsafe fn setup(build: &mut Build) {
103103 } ;
104104
105105 let parent = OpenProcess ( PROCESS_DUP_HANDLE , FALSE , pid. parse ( ) . unwrap ( ) ) ;
106- assert ! (
107- !parent. is_null( ) ,
108- "PID `{}` doesn't seem to exist: {}" ,
109- pid,
110- io:: Error :: last_os_error( )
111- ) ;
106+
107+ // If we get a null parent pointer here, it is possible that either
108+ // we have got an invalid pid or the parent process has been closed.
109+ // Since the first case rarely happens
110+ // (only when wrongly setting the environmental variable),
111+ // so it might be better to improve the experience of the second case
112+ // when users have interrupted the parent process and we don't finish
113+ // duplicating the handle yet.
114+ // We just need close the job object if that occurs.
115+ if parent. is_null ( ) {
116+ CloseHandle ( job) ;
117+ return ;
118+ }
119+
112120 let mut parent_handle = ptr:: null_mut ( ) ;
113121 let r = DuplicateHandle (
114122 GetCurrentProcess ( ) ,
You can’t perform that action at this time.
0 commit comments