Skip to content

Conversation

@robko23
Copy link

@robko23 robko23 commented Nov 14, 2025

When running buildctl-daemonless.sh outside of a container (e.g., locally), the script often failed to shut down the ephemeral buildkitd instance on exit. This left rootlesskit/buildkitd processes orphaned and reparented to PID 1. In some cases the script would also hang indefinitely during cleanup, requiring the user to abort with Ctrl+C.

The root cause was that the script stored the PID of the tee process (the log pipe) instead of the PID of the actual rootlesskit/buildkitd supervisor. As a result, the EXIT trap was killing the wrong process and the daemon continued running in the background.

This patch fixes the PID tracking by redirecting buildkitd logs to a file and spawning a separate tail -F process for live output. The PID file now contains the correct supervisor PID.

The cleanup trap was also improved: it now reliably terminates the correct process, and falls back to SIGKILL if the daemon does not shut down after SIGTERM.

…n daemonless script

When running buildctl-daemonless.sh outside of a container (e.g., locally), the
script often failed to shut down the ephemeral buildkitd instance on exit. This
left rootlesskit/buildkitd processes orphaned and reparented to PID 1. In some
cases the script would also hang indefinitely during cleanup, requiring the user
to abort with Ctrl+C.

The root cause was that the script stored the PID of the `tee` process (the log
pipe) instead of the PID of the actual rootlesskit/buildkitd supervisor. As a
result, the EXIT trap was killing the wrong process and the daemon continued
running in the background.

This patch fixes the PID tracking by redirecting buildkitd logs to a file and
spawning a separate `tail -F` process for live output. The PID file now contains
the correct supervisor PID.

The cleanup trap was also improved: it now reliably terminates the correct
process, and falls back to SIGKILL if the daemon does not shut down after
SIGTERM.

Signed-off-by: Robin Ilyk <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant