1
0
Fork 0
forked from ahurac/dotfiles

Réécriture légère de makeprio

This commit is contained in:
Hippolyte Chauvin 2023-05-08 11:02:50 +02:00
parent ac0a5bd169
commit 4a3539f8f4

View file

@ -1,38 +1,8 @@
#!/bin/bash #!/bin/sh -e
# Variables
sudo=sudo
renice=renice
pid="$(pidof "$1")" pid="$(pidof "$1")"
shift
prio="${1:--22}"
# Error function sudo renice "$prio" "$pid"
error() {
>&2 echo -e "\033[1;31mERROR:\033[0m $1"; shift
exit "${1:-1}"
}
# Test if process exists
if [[ -z $pid ]]; then
error "No such process." 1
else
shift
fi
# Arguments
prio="${1:--20}"; shift
# Command building
renice=(
"$sudo"
"$renice"
"$prio"
"$pid"
)
# Debug
#echo "${renice[@]}"
#exit 0
# Execution
"${renice[@]}"