You are not logged in.
Hello,
I'm trying to show pulsating progress bar while the background process is running. When 'Cancel' is clicked, I want the process that was started to be killed.
This is what I have so far:
#!/bin/bash
# shellcheck disable=SC2002
set -euo pipefail
spin() {
local -r pid="${!}"
local -r fifo="$(mktemp -u)"
mkfifo "${fifo}"
trap 'kill "${pid}"' HUP
cat "${fifo}" | zenity --progress --pulsate --auto-close --auto-kill --text="${1}" &
wait "${pid}"
echo "" > "${fifo}"
rm -f "${fifo}"
}
sleep 10 &
spin "sleeping"
This is the best I could come up with and this works, but I am wondering if there is a better way to do this without opening a FIFO, because zenity seems to send HUP to the parent which does not kill the process.
Offline