google-gemini / google-gemini/gemini-cli
Bug: list_background_processes prints (Exit Code: null) for signal-killed processes
- Dominant language
- TypeScript
- Stars
- 107k
- Forks
- 14.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 45
Description
### What happened?
`list_background_processes` prints `(Exit Code: null)` when a background process was killed by a signal (or backgrounded with `exitCode: null`).
`BackgroundProcess.exitCode` is `number | null | undefined` (`packages/core/src/services/shellExecutionService.ts`). Signal / backgrounded paths set `exitCode: null`.
The formatter only checks `!== undefined`:
```ts
// packages/core/src/tools/shellBackgroundTools.ts
p.exitCode !== undefined ? ` (Exit Code: ${p.exitCode})` : ''
```
null !== undefined is true, so the model sees:
- [PID 1234] EXITED: \sleep 60` (Exit Code: null)`
The exit-code clause should be omitted when there is no numeric code. Sibling checks in shell.ts already use !== null (e.g. around the display path). #29043 is the same class of bug in shell.ts sandbox-denial logic — this is the list-background-processes display path.
Repro:
Background a process, then kill it with a signal so exitCode === null.
Call list_background_processes.
Output contains (Exit Code: null).
Verified on current main.
### What did you expect to happen?
If exitCode is null or undefined, omit the exit-code clause.
If exitCode is a number, print (Exit Code: N).
If a signal is present, print (Signal: …) only.
### Client information
Reproduced from source on current main. Platform: macOS. CLI Version: 0.59.0-nightly.20260825.g812f7a2bc
### Login information
Not auth-related. Logic bug in list_background_processes formatting
### Anything else we need to know?
Suggested fix: change the guard to typeof p.exitCode === 'number'.
Add a unit test where exitCode is null and assert llmContent does not contain (Exit Code: null).
Related but not a duplicate of #29043 (different file and symptom).
I'd like to send a focused PR with tests after this is labeled help wanted.
Contributor guide
Research direction
Start in packages/core/src/tools/shellBackgroundTools.ts and inspect the exit-code formatter, then compare the sibling checks in shell.ts. Add a focused unit test covering exitCode null and verify numeric exit codes still appear. Done means list_background_processes omits the exit-code clause for null or undefined, while showing it for numbers and showing signal information when present.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- cli, testing-qa
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 88/100