Currently, I'm writing a Bash program that runs a program with different parameters based on a condition which changes over time, and exits when a key is pressed by the user. It is run with sudo, if that matters. However, read does not seem to be receiving any characters, and the script continues to run. Why does this occur, and how can I fix it? An example of what I'm trying:
(
read -sN1
exit
) &
while true; do
command param1 &
pid=$!
while condition; do true; done
kill $pid
command param2 &
pid=$!
until condition; do true; done
kill $pid
done