[PATCH 0/5] unshare: fix signal forwarding to child processes

Kiran Rangoon <[email protected]> Thu, 8 Jan 2026 13:31:29 -0500
Newsgroups org.kernel.vger.util-linux
Message-ID <[email protected]>
This series fixes a bug where unshare with --fork was not properly
forwarding SIGTERM and SIGINT to child processes, causing premature
termination during system shutdown.

The problem occurred because the parent process was blocking signals
instead of handling and forwarding them. When systemd sent SIGTERM
during shutdown, the parent would receive it but the child would
continue running until the kernel forcibly killed it. This resulted
in scripts being unable to handle SIGTERM traps properly and perform
cleanup operations.

The fix replaces signal blocking with signal handlers that forward
SIGTERM/SIGINT to the child process, allowing proper signal handling
and graceful shutdown. The waitpid loop is also updated to handle
EINTR interruptions from the signal forwarding mechanism.

Kiran Rangoon (5):
  unshare: add global child_pid variable for signal forwarding
  unshare: add signal forwarding handler
  unshare: replace signal blocking with signal handlers
  unshare: store child PID in global variable
  unshare: handle EINTR in waitpid loop

 sys-utils/unshare.c | 47 ++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 42 insertions(+), 5 deletions(-)

-- 
2.47.3