Skip to content

fix: avoid nil panic when terminating after a failed start - #109

Open
vulragrag-star wants to merge 2 commits into
cespare:mainfrom
vulragrag-star:fix/reflex-105-terminate-nil-process
Open

vulragrag-star wants to merge 2 commits into
cespare:mainfrom
vulragrag-star:fix/reflex-105-terminate-nil-process

Conversation

@vulragrag-star

Copy link
Copy Markdown

Summary

When a --start-service command fails to start (for example the binary is briefly missing during go install), running could stay true while cmd had a nil Process. The next restart path called terminate, which nil-dereferenced.

Failed starts now clear running, terminate nil-guards tty / Process, and terminate marks the reflex not running when it finishes.

Fixes #105

Test plan

  • go test -count=1 ./...
  • TestTerminateNilSafeAfterFailedStart
  • TestRunCommandFailedStartClearsRunning

Signed-off-by: Jason Wang vulragrag@gmail.com

If pty.Start fails after a prior successful service run, running could
stay true while cmd has a nil Process. The next terminate then
nil-dereferenced. Clear running on failed start, nil-guard tty/Process,
and mark not running when terminate finishes.

Fixes cespare#105
@NoFacePeace

NoFacePeace commented Sep 11, 2026 via email

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

panic: runtime error: invalid memory address or nil pointer dereference

2 participants