aboutsummaryrefslogtreecommitdiffstats
path: root/bash-completion
diff options
context:
space:
mode:
authorDaan De Meyer <daan.j.demeyer@gmail.com>2023-08-20 11:42:51 +0200
committerDaan De Meyer <daan.j.demeyer@gmail.com>2023-08-31 10:13:30 +0200
commitf092076fecc7ada2911df1b34f75091573ac08a8 (patch)
tree6396d01ab3b0ab94449d34af718d19df2462b20b /bash-completion
parent2b99ee2526ae61be761b0e31c50e106dbec5e9e4 (diff)
downloadutil-linux-f092076fecc7ada2911df1b34f75091573ac08a8.tar.gz
Add new setpgid utility
This program allows running a command in a new process group and optionally makes the new process group the foreground process group of the ctty. This is useful when running programs through wrappers programs (think bubblewrap, ...) and wanting to make sure that SIGINT is only sent to the innermost process. This is possible by putting the innermost process in a new process group and making that process group the foreground process group of the controlling terminal. By adding a separate utility to util-linux, we can apply this to any program even if the program itself doesn't implement this functionality.
Diffstat (limited to 'bash-completion')
-rw-r--r--bash-completion/Makemodule.am3
-rw-r--r--bash-completion/setpgid23
2 files changed, 26 insertions, 0 deletions
diff --git a/bash-completion/Makemodule.am b/bash-completion/Makemodule.am
index 2763895e89..c836d30b81 100644
--- a/bash-completion/Makemodule.am
+++ b/bash-completion/Makemodule.am
@@ -99,6 +99,9 @@ endif
if BUILD_SCRIPTLIVE
dist_bashcompletion_DATA += bash-completion/scriptlive
endif
+if BUILD_SETPGID
+dist_bashcompletion_DATA += bash-completion/setpgid
+endif
if BUILD_SETSID
dist_bashcompletion_DATA += bash-completion/setsid
endif
diff --git a/bash-completion/setpgid b/bash-completion/setpgid
new file mode 100644
index 0000000000..5ad9be564f
--- /dev/null
+++ b/bash-completion/setpgid
@@ -0,0 +1,23 @@
+_setpgid_module()
+{
+ local cur prev OPTS
+ COMPREPLY=()
+ cur="${COMP_WORDS[COMP_CWORD]}"
+ prev="${COMP_WORDS[COMP_CWORD-1]}"
+ case $prev in
+ '-h'|'--help'|'-V'|'--version')
+ return 0
+ ;;
+ esac
+ case $cur in
+ -*)
+ OPTS="--foreground --help --version"
+ COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+ return 0
+ ;;
+ esac
+ compopt -o bashdefault
+ COMPREPLY=( $(compgen -c -- $cur) )
+ return 0
+}
+complete -F _setpgid_module setpgid