MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / #handleExit

Method #handleExit

source code/utils/ShellCommand.ts:293–337  ·  view source on GitHub ↗
(code: number)

Source from the content-addressed store, hash-verified

291 }
292
293 async #handleExit(code: number): Promise<void> {
294 this.#cleanupListeners()
295 if (this.#status === 'running' || this.#status === 'backgrounded') {
296 this.#status = 'completed'
297 }
298
299 const stdout = await this.taskOutput.getStdout()
300 const result: ExecResult = {
301 code,
302 stdout,
303 stderr: this.taskOutput.getStderr(),
304 interrupted: code === SIGKILL,
305 backgroundTaskId: this.#backgroundTaskId,
306 }
307
308 if (this.taskOutput.stdoutToFile && !this.#backgroundTaskId) {
309 if (this.taskOutput.outputFileRedundant) {
310 // Small file — full content is in result.stdout, delete the file
311 void this.taskOutput.deleteOutputFile()
312 } else {
313 // Large file — tell the caller where the full output lives
314 result.outputFilePath = this.taskOutput.path
315 result.outputFileSize = this.taskOutput.outputFileSize
316 result.outputTaskId = this.taskOutput.taskId
317 }
318 }
319
320 if (this.#killedForSize) {
321 result.stderr = prependStderr(
322 `Background command killed: output file exceeded ${MAX_TASK_OUTPUT_BYTES_DISPLAY}`,
323 result.stderr,
324 )
325 } else if (code === SIGTERM) {
326 result.stderr = prependStderr(
327 `Command timed out after ${formatDuration(this.#timeout)}`,
328 result.stderr,
329 )
330 }
331
332 const resultResolver = this.#resultResolver
333 if (resultResolver) {
334 this.#resultResolver = null
335 resultResolver(result)
336 }
337 }
338
339 #doKill(code?: number): void {
340 this.#status = 'killed'

Callers

nothing calls this directly

Calls 6

#cleanupListenersMethod · 0.95
prependStderrFunction · 0.85
getStdoutMethod · 0.80
getStderrMethod · 0.80
deleteOutputFileMethod · 0.80
formatDurationFunction · 0.70

Tested by

no test coverage detected