public inbox for util-linux@vger.kernel.org
 help / color / mirror / Atom feed
From: Kiran Rangoon <kiranrangoon0@gmail.com>
To: util-linux@vger.kernel.org
Cc: kzak@redhat.com, Kiran Rangoon <kiranrangoon0@gmail.com>
Subject: [Patch V3 1/4] unshare: add --forward-signals option to argument parser
Date: Fri, 16 Jan 2026 12:06:45 -0500	[thread overview]
Message-ID: <20260116170648.26439-2-kiranrangoon0@gmail.com> (raw)
In-Reply-To: <20260116170648.26439-1-kiranrangoon0@gmail.com>

Add a new --forward-signals command-line option that will allow
unshare to forward SIGTERM and SIGINT signals from the parent
process to the forked child process.

This commit adds the option parsing infrastructure but does not
implement the signal forwarding logic yet. The flag defaults to 0
(disabled) to maintain backward compatibility.

Signed-off-by: Kiran Rangoon <kiranrangoon0@gmail.com>
---
 bash-completion/unshare | 1 +
 sys-utils/unshare.c     | 9 ++++++++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/bash-completion/unshare b/bash-completion/unshare
index 19eeb8f08..fdd40e5cb 100644
--- a/bash-completion/unshare
+++ b/bash-completion/unshare
@@ -28,6 +28,7 @@ _unshare_module()
 				--cgroup
 				--time
 				--fork
+				--forward-signals
 				--kill-child
 				--keep-caps
 				--mount-proc
diff --git a/sys-utils/unshare.c b/sys-utils/unshare.c
index 5370ab981..8a7a26df2 100644
--- a/sys-utils/unshare.c
+++ b/sys-utils/unshare.c
@@ -769,6 +769,7 @@ static void __attribute__((__noreturn__)) usage(void)
 	fputs(_(" -f, --fork                fork before launching <program>\n"), out);
 	fputs(_(" --kill-child[=<signame>]  when dying, kill the forked child (implies --fork)\n"
 		"                             defaults to SIGKILL\n"), out);
+	fputs(_(" --forward-signals         forward SIGTERM and SIGINT to child (implies --fork)\n"), out);
 	fputs(USAGE_SEPARATOR, out);
 	fputs(_(" --setgroups allow|deny    control the setgroups syscall in user namespaces\n"), out);
 	fputs(_(" --keep-caps               retain capabilities granted in user namespaces\n"), out);
@@ -801,6 +802,7 @@ int main(int argc, char *argv[])
 		OPT_MAPAUTO,
 		OPT_MAPSUBIDS,
 		OPT_OWNER,
+		OPT_FORWARD_SIGNALS,
 	};
 	static const struct option longopts[] = {
 		{ "help",          no_argument,       NULL, 'h'             },
@@ -817,6 +819,7 @@ int main(int argc, char *argv[])
 
 		{ "fork",          no_argument,       NULL, 'f'             },
 		{ "kill-child",    optional_argument, NULL, OPT_KILLCHILD   },
+		{ "forward-signals", no_argument,     NULL, OPT_FORWARD_SIGNALS },
 		{ "mount-proc",    optional_argument, NULL, OPT_MOUNTPROC   },
 		{ "mount-binfmt",  optional_argument, NULL, OPT_MOUNTBINFMT },
 		{ "map-user",      required_argument, NULL, OPT_MAPUSER     },
@@ -843,7 +846,7 @@ int main(int argc, char *argv[])
 
 	int setgrpcmd = SETGROUPS_NONE;
 	int unshare_flags = 0;
-	int c, forkit = 0;
+	int c, forkit = 0, forward_signals = 0;
 	uid_t mapuser = -1, owneruser = -1;
 	gid_t mapgroup = -1, ownergroup = -1;
 	struct map_range *usermap = NULL;
@@ -1015,6 +1018,10 @@ int main(int argc, char *argv[])
 			keepcaps = 1;
 			cap_last_cap(); /* Force last cap to be cached before we fork. */
 			break;
+		case OPT_FORWARD_SIGNALS:
+			forkit = 1;
+			forward_signals = 1;
+			break;
 		case 'S':
 			uid = strtoul_or_err(optarg, _("failed to parse uid"));
 			force_uid = 1;
-- 
2.47.3


  reply	other threads:[~2026-01-16 17:06 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-08 18:31 [PATCH 0/5] unshare: fix signal forwarding to child processes Kiran Rangoon
2026-01-08 18:31 ` [PATCH 1/5] unshare: add global child_pid variable for signal forwarding Kiran Rangoon
2026-01-08 18:31 ` [PATCH 2/5] unshare: add signal forwarding handler Kiran Rangoon
2026-01-08 18:31 ` [PATCH 3/5] unshare: replace signal blocking with signal handlers Kiran Rangoon
2026-01-08 18:31 ` [PATCH 4/5] unshare: store child PID in global variable Kiran Rangoon
2026-01-08 18:31 ` [PATCH 5/5] unshare: handle EINTR in waitpid loop Kiran Rangoon
2026-01-12 14:05 ` [PATCH 0/5] unshare: fix signal forwarding to child processes Karel Zak
2026-01-13 17:29   ` [Patch V2 0/4] " Kiran Rangoon
2026-01-13 17:29     ` [V2 1/4] unshare: add --forward-signals option to argument parser Kiran Rangoon
2026-01-13 17:29     ` [V2 2/4] unshare: implement signal forwarding when --forward-signals is used Kiran Rangoon
2026-01-13 17:29     ` [V2 3/4] unshare: document --forward-signals in man page Kiran Rangoon
2026-01-13 17:29     ` [V2 4/4] tests: add tests for unshare --forward-signals Kiran Rangoon
2026-01-16 17:06       ` [PATCH V3 0/4] unshare: add --forward-signals option Kiran Rangoon
2026-01-16 17:06         ` Kiran Rangoon [this message]
2026-01-16 17:06         ` [Patch V3 2/4] unshare: implement signal forwarding when --forward-signals is used Kiran Rangoon
2026-01-16 17:06         ` [Patch V3 3/4] unshare: document --forward-signals in man page Kiran Rangoon
2026-01-16 17:06         ` [Patch V3 4/4] tests: add tests for unshare --forward-signals Kiran Rangoon
2026-01-21  8:37         ` [PATCH V3 0/4] unshare: add --forward-signals option Karel Zak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260116170648.26439-2-kiranrangoon0@gmail.com \
    --to=kiranrangoon0@gmail.com \
    --cc=kzak@redhat.com \
    --cc=util-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox