Skip to content

Commit 64ee304

Browse files
committed
Removed unnecessary pid checks
1 parent c96e64f commit 64ee304

File tree

1 file changed

+3
-30
lines changed

1 file changed

+3
-30
lines changed

packages/core/src/codewhispererChat/tools/executeBash.ts

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -343,43 +343,16 @@ exec bash -c "
343343
if (this.isTriggerCancelled()) {
344344
this.logger.debug('Trigger cancellation detected, killing child process')
345345

346-
// First try to kill the entire process group
347-
if (this.childProcess && this.childProcess.pid) {
348-
try {
349-
// On Unix systems, negative PID kills the process group
350-
const childProcessPid = this.childProcess.pid
351-
const pid = -childProcessPid
352-
this.logger.debug(`Sending SIGTERM to process group ${pid}`)
353-
process.kill(pid, 'SIGTERM')
354-
} catch (err) {
355-
this.logger.debug(`Failed to kill process group: ${err}`)
356-
// Fall back to regular process termination
357-
this.childProcess?.stop(false, 'SIGTERM')
358-
}
359-
} else {
360-
this.childProcess?.stop(false, 'SIGTERM')
361-
}
346+
// Kill the process
347+
this.childProcess?.stop(false, 'SIGTERM')
362348

363349
// After a short delay, force kill with SIGKILL if still running
364350
setTimeout(() => {
365351
if (this.childProcess && !this.childProcess.stopped) {
366352
this.logger.debug('Process still running after SIGTERM, sending SIGKILL')
367353

368354
// Try to kill the process group with SIGKILL
369-
if (this.childProcess.pid) {
370-
try {
371-
const childProcessPid = this.childProcess.pid
372-
const pid = -childProcessPid
373-
this.logger.debug(`Sending SIGKILL to process group ${pid}`)
374-
process.kill(pid, 'SIGKILL')
375-
} catch (err) {
376-
this.logger.debug(`Failed to kill process group with SIGKILL: ${err}`)
377-
// Fall back to regular process termination
378-
this.childProcess.stop(true, 'SIGKILL')
379-
}
380-
} else {
381-
this.childProcess.stop(true, 'SIGKILL')
382-
}
355+
this.childProcess.stop(true, 'SIGKILL')
383356
}
384357
}, 500)
385358

0 commit comments

Comments
 (0)