{"record":{"id":"1c3a94121a031421","repo":"deepseek-ai/deepseek-harness","slug":"terminal-cleanup-failed-surviving-pid-this-pid","errorCode":null,"errorMessage":"terminal cleanup failed; surviving pid: ${this.pid}","messagePattern":"terminal cleanup failed; surviving pid: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/subprocess/subprocess-local/src/terminal.ts","lineNumber":252,"sourceCode":"      return\n    }\n    if (!this.exited) {\n      try {\n        this.terminal.kill('SIGTERM')\n      } catch (_topLevelAlreadyExitedDuringTerm) {\n        // The exit callback is authoritative.\n      }\n      await Promise.race([this.done.then(() => undefined), delay(this.graceMs)])\n    }\n    if (!this.exited) {\n      try {\n        this.terminal.kill('SIGKILL')\n      } catch (_topLevelAlreadyExitedDuringKill) {\n        // The exit callback is authoritative.\n      }\n      await Promise.race([this.done.then(() => undefined), delay(this.graceMs)])\n    }\n    if (!this.exited) throw new Error(`terminal cleanup failed; surviving pid: ${this.pid}`)\n  }\n\n  private async stopShellWindows(): Promise<void> {\n    // node-pty's Windows kill(signal) throws (\"Signals not supported on\n    // windows\"), and its bare kill() delegates to a console-list agent that\n    // fails when the parent has no console. taskkill tree escalation is the\n    // teardown path, fenced on the shell's start identity like every\n    // descendant; a root identity miss falls back to the bare kill. taskkill\n    // termination also does not reliably fire node-pty's exit notification\n    // (the same console-list agent), so the tiers verify the shell's absence\n    // through the inspector instead of waiting on `done` alone.\n    const shellGone = (): boolean =>\n      this.exited || (this.rootIdentity !== undefined && !this.inspector.isAlive(this.rootIdentity))\n    if (!shellGone() && this.rootIdentity !== undefined) {\n      this.inspector.signalProcess(this.rootIdentity, 'SIGTERM')\n      await this.waitForWindowsShellExit()\n    }\n    if (!shellGone() && this.rootIdentity === undefined) {","sourceCodeStart":234,"sourceCodeEnd":270,"githubUrl":"https://github.com/deepseek-ai/deepseek-harness/blob/b150a551b8d465e31e418e1b2eaf5e79bbb7d28e/packages/subprocess/subprocess-local/src/terminal.ts#L234-L270","documentation":"Error \"terminal cleanup failed; surviving pid: ${this.pid}\" thrown in deepseek-ai/deepseek-harness.","triggerScenarios":"Thrown at packages/subprocess/subprocess-local/src/terminal.ts:252 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Kill the surviving pid manually and check why the process ignored termination (permissions, uninterruptible state)."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b150a551b8d465e31e418e1b2eaf5e79bbb7d28e","analyzedAt":"2026-08-24T18:12:29.105Z","schemaVersion":2},"datasetVersion":"2026-08-24T22:17:12.610Z"}