[PATCH 1/5] unshare: add global child_pid variable for signal forwarding

Kiran Rangoon <[email protected]> Thu, 8 Jan 2026 13:31:30 -0500
Newsgroups org.kernel.vger.util-linux
Message-ID <[email protected]>
Add a global variable to store the child process PID, which will be
used by the signal handler to forward SIGTERM/SIGINT to the child.

Signed-off-by: Kiran Rangoon <[email protected]>
---
 sys-utils/unshare.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/sys-utils/unshare.c b/sys-utils/unshare.c
index 5370ab981..6df53666a 100644
--- a/sys-utils/unshare.c
+++ b/sys-utils/unshare.c
@@ -74,6 +74,9 @@ static struct namespace_file {
 
 static int npersists;	/* number of persistent namespaces */
 
+/* Global PID of child process for signal forwarding */
+static volatile pid_t child_pid = 0;
+
 enum {
 	SETGROUPS_NONE = -1,
 	SETGROUPS_DENY = 0,
-- 
2.47.3