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

Abierto Apto para principiantes
#180 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
68/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Tranquilo
Stack tecnológico
go
Área
cli

Línea de trabajo

Empieza en internal/daemon/stop.go, en stopTargets, donde el error de stopSignal se añade al error unido. El emisor POSIX es sendStop en internal/daemon/stop_posix.go. Decide si un resultado os.ErrProcessDone cuenta como detenido o se omite, y luego gestiónalo con errors.Is. Está listo cuando una prueba que inyecta os.ErrProcessDone a través de la costura stopSignal muestra que daemon stop no devuelve ningún error.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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

Lenguaje dominante
Go
Estrellas
0
Forks
0
Merge medio
7 h 42 min
PR fusionados (30 d)
111

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de seanb4t/codegraph-go

Todos los issues de seanb4t/codegraph-go

Issues similares

Más issues de Go

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.