Skip to content

Add --forward-signals option - #812

Open
birneee wants to merge 1 commit into
containers:mainfrom
birneee:forward-signals
Open

birneee wants to merge 1 commit into
containers:mainfrom
birneee:forward-signals

Conversation

@birneee

@birneee birneee commented Oct 2, 2026 •

Copy link
Copy Markdown

An alternative implementation of #586, which no longer merges, taking the
option name and approach from it and #402.

It addresses the two points from the review there: the init process stops
forwarding once it has reaped the command, so a reused pid is never signalled,
and the hook sits in do_init() rather than keyed off --unshare-pid, so
--lock-file and --sync-fd are covered as well. --as-pid-1 stays allowed,
documented as only receiving signals the command has a handler for. SIGWINCH is
included, so this closes #573 too.

One caveat: should_forward_signal() calls getpgid() from init's signal
handler, which POSIX does not list among the functions guaranteed safe there,
though on Linux it is a bare system call. Dropping it would stop terminal
signals reaching a command that has left bwrap's process group; the alternative
is a signalfd in init instead of handlers.

🤖 Generated/Co-authored with Claude Code

Forward signals sent to bwrap on to the sandboxed command, through the init
process.

Forwarding stops once init has reaped the command, as the kernel can then
give its pid to an unrelated process.

Signals the kernel sent to our process group are not forwarded, as the
command received those itself unless it has left the group.

Inspired by containers#402 and containers#586.

Resolves: containers#369
Resolves: containers#573
Signed-off-by: Benedikt Spies <benedikt.spies@gmail.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.

Pass WINCH signal to child process

1 participant