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

Đang mở Phù hợp với người mới
#180 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
68/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
go
Lĩnh vực
cli

Hướng nghiên cứu

Bắt đầu từ internal/daemon/stop.go, trong stopTargets, nơi lỗi từ stopSignal được nối vào lỗi gộp. Bên gửi POSIX là sendStop trong internal/daemon/stop_posix.go. Quyết định xem kết quả os.ErrProcessDone được tính là đã dừng hay bị bỏ qua, rồi xử lý nó bằng errors.Is. Hoàn thành khi một bài kiểm thử tiêm os.ErrProcessDone qua điểm nối stopSignal cho thấy daemon stop không trả về lỗi nào.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

Ngôn ngữ chính
Go
Star
0
Fork
0
Merge trung bình
7 giờ 42 phút
Pull request đã merge (30 ngày)
111

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của seanb4t/codegraph-go

Tất cả issue của seanb4t/codegraph-go

Issue tương tự

Thêm issue về Go

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.