help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] Event if pipe closes? Check if pipe is still open?


From: Greg Wooledge
Subject: Re: [Help-bash] Event if pipe closes? Check if pipe is still open?
Date: Mon, 3 Jun 2013 09:02:04 -0400
User-agent: Mutt/1.4.2.3i

On Fri, May 31, 2013 at 10:57:02PM +0000, adrelanos wrote:
> Hi!
> 
> Example:
> 
>    exec 3> >(\
>       zenity \
>       --display="$DISPLAY" \
>       --timeout "86400" \
>       --no-markup \
>       --window-icon "/usr/share/whonix/icons/whonix.ico" \
>       --title=" $TITLE " \
>       --progress \
>       --auto-close \
>       --auto-kill \
>       --text "$NOTIFY_MSG"\
>    )
> 
> This works in principle quite nicely, I can use for example 'echo "50"
> >&3' and the progress meter moves to 50%. I just don't know when the
> user clicked "cancel".

Instead of checking whether a "pipe is still open", check whether the
background process is still running.  This means that you need to
launch it explicitly as a background process, instead of using the
process substitution shortcut syntax.

trap 'rm -f myfifo' EXIT
mkfifo myfifo
zenity --display="$DISPLAY" ... < myfifo & zenitypid=$!
exec 3>myfifo

(Of course in practice you'd probably use an absolute path to your FIFO,
and it would be in /tmp or /var/tmp or $HOME/tmp or something....)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]