File tree 1 file changed +18
-2
lines changed
1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,15 @@ export const killPsTree = async (
16
16
const pids = [ rootPid , ...childPids ] ;
17
17
18
18
for ( const pid of pids ) {
19
- process . kill ( pid , 'SIGTERM' ) ;
19
+ try {
20
+ process . kill ( pid , 'SIGTERM' ) ;
21
+ } catch ( error ) {
22
+ if ( error . code === 'ESRCH' ) {
23
+ log . debug ( { pid } , 'process already terminated' ) ;
24
+ } else {
25
+ throw error ;
26
+ }
27
+ }
20
28
}
21
29
22
30
let hangingPids = [ ...pids ] ;
@@ -29,7 +37,15 @@ export const killPsTree = async (
29
37
log . debug ( { hangingPids } , 'sending SIGKILL to processes...' ) ;
30
38
31
39
for ( const pid of hangingPids ) {
32
- process . kill ( pid , 'SIGKILL' ) ;
40
+ try {
41
+ process . kill ( pid , 'SIGKILL' ) ;
42
+ } catch ( error ) {
43
+ if ( error . code === 'ESRCH' ) {
44
+ log . debug ( { pid } , 'process already terminated' ) ;
45
+ } else {
46
+ throw error ;
47
+ }
48
+ }
33
49
}
34
50
} , gracefulTimeout ) ;
35
51
You can’t perform that action at this time.
0 commit comments