Basically, I am trying to exit a subshell that contains a loop. Here is the code: `
stop=0
( # subshell start
while true # Loop start
do
sleep 1 # Wait a second
echo 1 >> /tmp/output # Add a line to a test file
if [ $stop = 1 ]; then exit; fi # This should exit the subshell if $stop is 1
done # Loop done
) | # Do I need this pipe?
while true
do
zenity --title="Test" --ok-label="Stop" --cancel-label="Refresh" --text-info --filename=/tmp/output --font=couriernew # This opens Zenity and shows the file. It returns 0 when I click stop.
if [ "$?" = 0 ] # If Zenity returns 0, then
then
let stop=1 # This should close the subshell, and
break # This should close this loop
fi
done # This loop end
echo Done
This does not work. It never says Done. When I press Stop it just closes the dialog, but keeps writing to the file.
Edit: I need to be able to pass a variable from the subshell to the parent shell. However, I need to keep writing to the file and keep the Zenity dialog coming up. How would I do this?