File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change
1
+ import { isWin } from "./Platform" ;
2
+
1
3
/**
2
4
* @param {number } pid process id. Required.
3
5
* @returns boolean true if the given process id is in the local process
@@ -15,6 +17,13 @@ export function pidExists(pid: number | undefined): boolean {
15
17
// exist. EPERM means it _does_ exist!
16
18
if ( ( err as NodeJS . ErrnoException ) ?. code === "EPERM" ) return true ;
17
19
20
+ // On Windows, some error codes might indicate the process is terminating
21
+ // but hasn't fully exited yet. Treat these as "not existing" to avoid
22
+ // race conditions during shutdown.
23
+ if ( isWin && ( err as NodeJS . ErrnoException ) ?. code === "EINVAL" ) {
24
+ return false ;
25
+ }
26
+
18
27
// failed to get priority--assume the pid is gone.
19
28
return false ;
20
29
}
You can’t perform that action at this time.
0 commit comments