fix(daemon): daemon stop reports a failed stop for a daemon that exits just before SIGTERM

Aperta Adatta ai principianti
#180 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
68/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Tranquilla
Stack tecnologico
go
Ambito
cli

Direzione di ricerca

Inizia da internal/daemon/stop.go, in stopTargets, dove l'errore di stopSignal viene aggiunto all'errore unito. Il mittente POSIX è sendStop in internal/daemon/stop_posix.go. Decidi se un risultato os.ErrProcessDone conta come fermato o viene saltato, quindi gestiscilo con errors.Is. È completato quando un test che inietta os.ErrProcessDone tramite il punto di iniezione stopSignal mostra che daemon stop non restituisce alcun errore.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug priority:low spec-needed

Problem

stopTargets (internal/daemon/stop.go) checks each record with isStale, and then sends SIGTERM through stopSignal. On POSIX that is sendStop (internal/daemon/stop_posix.go): os.FindProcess(pid), then proc.Signal(syscall.SIGTERM).

A daemon can exit between the isStale check and the signal. proc.Signal then returns os.ErrProcessDone ("os: process already finished"), and stopTargets adds it to the joined error:

if err := stopSignal(rec.PID); err != nil {
	errs = append(errs, fmt.Errorf("stopping pid %d: %w", rec.PID, err))
	continue
}

So codegraph daemon stop exits 1 with stopping pid N: os: process already finished, although the daemon is gone, which is what the user asked for. With #179, a stop that stopped nothing and failed prints nothing on stdout, so the user sees only that error.

Evidence

  • A scratch program in the suite review of #179 showed that SIGTERM to an exited pid returns os.ErrProcessDone.
  • The race was not reproduced through the command itself. The window between isStale and the signal is short.

Possible direction

  • In stopTargets, handle errors.Is(err, os.ErrProcessDone) without adding an error.
  • Decide whether such a record counts as stopped (the process is gone, so stopped pid N is true) or is skipped like a stale record.
  • Add a test through the stopSignal seam that returns os.ErrProcessDone.

Found by the silent-failure reviewer in the suite review of #179 (finding QUAL-4, PLAUSIBLE). The code predates #179.

🤖 Generated with Claude Code

https://claude.ai/code/session_01XFrTgTHsJM948TTYmCDjP5

Lingua principale
Go
Stelle
0
Fork
0
Merge medio
7h 42m
PR unite (30g)
111

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di seanb4t/codegraph-go

Tutte le issue di seanb4t/codegraph-go

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.