@@ -77,6 +77,7 @@ static bool opt_unshare_cgroup = false;
7777static bool opt_unshare_cgroup_try = false;
7878static bool opt_needs_devpts = false;
7979static bool opt_new_session = false;
80+ static bool opt_ignore_keyboard_signals = false;
8081static bool opt_die_with_parent = false;
8182static uid_t opt_sandbox_uid = -1 ;
8283static 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 ));
0 commit comments