Skip to content

Commit 76d6f2b

Browse files
committed
Add an --ignore-keyboard-signals option
Signed-off-by: GalaxySnail <me@glxys.nl>
1 parent 0c408e1 commit 76d6f2b

3 files changed

Lines changed: 15 additions & 0 deletions

File tree

bubblewrap.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ static bool opt_unshare_cgroup = false;
7777
static bool opt_unshare_cgroup_try = false;
7878
static bool opt_needs_devpts = false;
7979
static bool opt_new_session = false;
80+
static bool opt_ignore_keyboard_signals = false;
8081
static bool opt_die_with_parent = false;
8182
static uid_t opt_sandbox_uid = -1;
8283
static gid_t opt_sandbox_gid = -1;
@@ -366,6 +367,7 @@ usage (int ecode, FILE *out)
366367
" --info-fd FD Write information about the running container to FD\n"
367368
" --json-status-fd FD Write container status to FD as multiple JSON documents\n"
368369
" --new-session Create a new terminal session\n"
370+
" --ignore-keyboard-signals Ignore SIGINT and SIGQUIT while waiting for the command to terminate\n"
369371
" --die-with-parent Kills with SIGKILL child process (COMMAND) when bwrap or bwrap's parent dies.\n"
370372
" --as-pid-1 Do not install a reaper process with PID=1\n"
371373
" --cap-add CAP Add cap CAP when running as privileged user\n"
@@ -2592,6 +2594,10 @@ parse_args_recurse (int *argcp,
25922594
{
25932595
opt_new_session = true;
25942596
}
2597+
else if (strcmp (arg, "--ignore-keyboard-signals") == 0)
2598+
{
2599+
opt_ignore_keyboard_signals = true;
2600+
}
25952601
else if (strcmp (arg, "--die-with-parent") == 0)
25962602
{
25972603
opt_die_with_parent = true;
@@ -3210,6 +3216,13 @@ main (int argc,
32103216
close (opt_userns_block_fd);
32113217
}
32123218

3219+
if (opt_ignore_keyboard_signals)
3220+
{
3221+
struct sigaction sa_ign = { .sa_handler = SIG_IGN };
3222+
sigaction(SIGINT, &sa_ign, NULL);
3223+
sigaction(SIGQUIT, &sa_ign, NULL);
3224+
}
3225+
32133226
/* Let child run now that the uid maps are set up */
32143227
val = 1;
32153228
res = TEMP_FAILURE_RETRY (write (child_wait_fd, &val, 8));

completions/bash/bwrap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ _bwrap() {
1414
--clearenv
1515
--disable-userns
1616
--help
17+
--ignore-keyboard-signals
1718
--new-session
1819
--unshare-all
1920
--unshare-cgroup

completions/zsh/_bwrap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ _bwrap_args=(
4949
'--gid[Custom gid in the sandbox (requires --unshare-user or --userns)]: :_guard "[0-9]#" "numeric group ID"'
5050
'--help[Print help and exit]'
5151
'--hostname[Custom hostname in the sandbox (requires --unshare-uts)]:hostname:'
52+
'--ignore-keyboard-signals[Ignore SIGINT and SIGQUIT while waiting for the command to terminate]'
5253
'--info-fd[Write information about the running container to FD]: :_guard "[0-9]#" "file descriptor to write to"'
5354
'--json-status-fd[Write container status to FD as multiple JSON documents]: :_guard "[0-9]#" "file descriptor to write to"'
5455
'--lock-file[Take a lock on DEST while sandbox is running]:lock file:_files'

0 commit comments

Comments
 (0)