Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Processes a command leaves behind are never killed on Stop, chat close or quit

Closed
#165 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
49/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
typescript
Domain
cli, desktop

Research direction

Start with src/main/tools/shell.ts, especially killTree at line 378 and the foreground run flow around line 221; trace how background commands are stopped and how output draining is handled. Check the platform-specific process cleanup paths, including the AppContainer behavior. Done means the proposed tests pass: Stop after sleep 100 & leaves no process behind, and a foreground run also leaves no process behind.

Written by the indexing model from the issue text.

Description

bug priority: high severity: medium

Found in the 2026-10-07 code review (traced through the code; not run on POSIX).

Problem

killTree (src/main/tools/shell.ts:378) returns early when child.exitCode !== null. exitCode is set as soon as the shell exits, while programs it started (its process group on POSIX) can keep running and keep the pipes open. So the group is never signalled.

  • Background commands: close never fires, so the entry stays "running", and stopBackground → killTree does nothing.
  • Foreground commands: run resolves 500 ms after exit (:221), and the leftover process isn't tracked at all.

AppContainer is not affected, because KILL_ON_JOB_CLOSE ends the whole job.

Scenario

The model runs npm run dev &, which models often do even with background: true. bash exits, and Stop, closing the chat or project, and quitting the app all leave the dev server running. The next npm run dev then fails with "port in use".

Fix

  • On POSIX, always run process.kill(-child.pid, 'SIGKILL') (ESRCH is already caught). Do it in killTree regardless of exitCode, and also once a foreground run's output has drained (or keep the pgid and kill it in stopAll).
  • On Windows without a sandbox, put the child in a job object (or record its descendants), because taskkill /T can't find orphans.
  • Tests: Stop after sleep 100 & leaves no process behind, and the same after a foreground run finishes.
Dominant language
TypeScript
Stars
2
Forks
2
Avg merge
5h 28m
Merged PRs (30d)
24

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from PierrunoYT/patch

All issues in PierrunoYT/patch

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.