File tree 1 file changed +14
-2
lines changed
src/client/common/process 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -75,10 +75,21 @@ export function shellExec(
75
75
resolve ( { stderr : stderr && stderr . length > 0 ? stderr : undefined , stdout } ) ;
76
76
}
77
77
} ;
78
+ let procExited = false ;
78
79
const proc = exec ( command , shellOptions , callback ) ; // NOSONAR
80
+ proc . once ( 'close' , ( ) => {
81
+ procExited = true ;
82
+ } ) ;
83
+ proc . once ( 'exit' , ( ) => {
84
+ procExited = true ;
85
+ } ) ;
86
+ proc . once ( 'error' , ( ) => {
87
+ procExited = true ;
88
+ } ) ;
79
89
const disposable : IDisposable = {
80
90
dispose : ( ) => {
81
- if ( ! proc . killed ) {
91
+ // If process has not exited nor killed, force kill it.
92
+ if ( ! procExited && ! proc . killed ) {
82
93
if ( proc . pid ) {
83
94
killPid ( proc . pid ) ;
84
95
} else {
@@ -114,7 +125,8 @@ export function plainExec(
114
125
const deferred = createDeferred < ExecutionResult < string > > ( ) ;
115
126
const disposable : IDisposable = {
116
127
dispose : ( ) => {
117
- if ( ! proc . killed ) {
128
+ // If process has not exited nor killed, force kill it.
129
+ if ( ! proc . killed && ! deferred . completed ) {
118
130
if ( proc . pid ) {
119
131
killPid ( proc . pid ) ;
120
132
} else {
You can’t perform that action at this time.
0 commit comments