Skip to content

watch: handle SIGHUP in watcher interrupt path#2725

Open
SergioChan wants to merge 2 commits intogo-task:mainfrom
SergioChan:fix-watcher-sighup-2642
Open

watch: handle SIGHUP in watcher interrupt path#2725
SergioChan wants to merge 2 commits intogo-task:mainfrom
SergioChan:fix-watcher-sighup-2642

Conversation

@SergioChan
Copy link
Contributor

@SergioChan SergioChan commented Mar 8, 2026

Summary

  • include syscall.SIGHUP in the watcher interrupt signal handler
  • watcher mode now exits/restarts on SIGHUP just like SIGINT/SIGTERM

Testing

  • Unable to run go test ./... locally in this environment because the repository requests Go 1.25 toolchain and automatic toolchain download is unavailable here (toolchain not available).
  • Change is a single signal list update in closeOnInterrupt, with no behavioral impact outside watch-mode signal handling.

Related

@trulede
Copy link
Contributor

trulede commented Mar 15, 2026

What would happen if both SIGTERM and SIGHUP are received in quick succession? Is it going to restart the watcher, or exit Task.

Possibly call signal.Stop(ch) before w.Close(),

@trulede trulede added the area: watcher Changes related to the Taskfile watcher. label Mar 15, 2026
@SergioChan
Copy link
Contributor Author

Good point — I pushed a follow-up commit (21afafb8) to make the signal path explicit and avoid double-delivery races.

Change

  • Added signal.Stop(ch) before w.Close() in closeOnInterrupt.

Effect

  • Once the first interrupt signal is received, we stop further notifications on that channel before closing the watcher and exiting.
  • This avoids handling a rapid second signal on the same channel while shutdown is already in progress.

Behavior remains the same (watch process exits on SIGINT/SIGTERM/SIGHUP), but the shutdown path is now safer/cleaner.

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

Labels

area: watcher Changes related to the Taskfile watcher.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Watcher interrupt on SIGHUP

2 participants