File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed
Expand file tree Collapse file tree 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 (
1616 const pids = [ rootPid , ...childPids ] ;
1717
1818 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+ }
2028 }
2129
2230 let hangingPids = [ ...pids ] ;
@@ -29,7 +37,15 @@ export const killPsTree = async (
2937 log . debug ( { hangingPids } , 'sending SIGKILL to processes...' ) ;
3038
3139 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+ }
3349 }
3450 } , gracefulTimeout ) ;
3551
You can’t perform that action at this time.
0 commit comments