Skip to content

Comments

fix: isolate dind cleanup subprocesses from Ctrl+C SIGINT#3

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/fix-error-on-exit-ctrl-c
Draft

fix: isolate dind cleanup subprocesses from Ctrl+C SIGINT#3
Copilot wants to merge 2 commits intomainfrom
copilot/fix-error-on-exit-ctrl-c

Conversation

Copy link

Copilot AI commented Feb 22, 2026

Pressing Ctrl+C broadcasts SIGINT to the entire foreground process group, which killed the docker stop/docker rm/docker network rm subprocesses in Stop() before they could complete — leaving the dind container and network alive and producing the cascade of errors.

Changes

  • run() helper — calls setSysProcAttr(cmd), which sets Setpgid: true on Unix, placing each cleanup subprocess in its own process group and shielding it from the terminal's SIGINT
  • Stop() — replaces two-step docker stop + docker rm with atomic docker rm -f, eliminating the race window between the two calls
  • sysattr_unix.go / sysattr_windows.go — platform build tags to keep syscall.SysProcAttr out of the Windows build path
func run(name string, args ...string) (string, error) {
    cmd := exec.Command(name, args...)
    setSysProcAttr(cmd) // Setpgid: true on Unix — new process group, no SIGINT propagation
    out, err := cmd.CombinedOutput()
    return string(out), err
}
Original prompt

This section details on the original issue you should resolve

<issue_title>error when exiting with ctrl+c</issue_title>
<issue_description>^Cconstruct: stop dind: exit status 130

construct: rm dind: exit status 1
Error response from daemon: cannot remove container "construct-dind-8d8cdb6c7c7cdbf6": container is running: stop the container before removing or force remove

construct: rm network: exit status 1
Error response from daemon: error while removing network: network construct-net-8d8cdb6c7c7cdbf6 has active endpoints (name:"construct-dind-8d8cdb6c7c7cdbf6" id:"86facf98d546")
exit status 1
</issue_description>

Comments on the Issue (you are @copilot in this section)


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

…Ctrl+C

When Ctrl+C is pressed the terminal SIGINT is broadcast to the entire
foreground process group. The docker stop/rm/network-rm subprocesses
spawned by Stop() were in that group and exited with code 130 before
completing, leaving the dind container and network running.

- Add setSysProcAttr() (platform-specific) to place each cleanup
  subprocess in its own process group (Setpgid: true on Unix), shielding
  it from the terminal's SIGINT.
- Replace docker stop + docker rm with docker rm -f, which force-kills
  and removes the container atomically, eliminating the "container is
  running" error even if the stop step were somehow interrupted.

Co-authored-by: mtsfoni <80639729+mtsfoni@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix error when exiting with ctrl+c during container operations fix: isolate dind cleanup subprocesses from Ctrl+C SIGINT Feb 22, 2026
Copilot AI requested a review from mtsfoni February 22, 2026 02:57
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.

error when exiting with ctrl+c

2 participants