I want to create a pair of bash functions something along the lines of
function generator {
while [ 1 -le 1 ]
do
# run log generator > somefile.log
done
}
function tail_log {
generator &
tail -f somefile.log
}
So, I would run the command tail_log to see the log output. Except, instead of the infinite loop, I'd like allow the user to press Q to terminate the forked process.
So it looks like I need two things:
- a way to get the process ID of a forked prcoess
- a way to listen for user input so I can
killthe process ID when the user pressesQ