[gtk-server] Re: busy loop on startup with fifo method
- From: Peter van Eerten <administrator@xxxxxxxxxxxxxx>
- To: gtk-server@xxxxxxxxxxxxx, Frantisek Dufka <dufkaf@xxxxxxxxx>
- Date: Tue, 17 Apr 2007 21:08:33 +0200
Quoting Frantisek Dufka <dufkaf@xxxxxxxxx>:
Ah, I see, it is easy then. Or at least in some situations. I was
thinking about killing gtk-server when there is some error or script is
interrupted via ctrl-c. Just tried it and indeed it doesn't work very
good when hitting ctrl+c. When script is waiting inside gtk
"gtk_server_callback WAIT" and I call another gtk "gtk_exit 0" from
trap handler it does not do the right thing (i.e exit gtk server) it
simply prints error and does nothing
./demo-fifo.sh: 1: cannot create /tmp/gtk-server-fifo.2613: Interrupted
system call
In such cases it may be easier to kill gtk-server directly and the
correct PID is in $! after running gtk-server with & so it is easy.
With gtk server forking to background you would need to hunt it down
via ps and grep. This simple code works as expected
end(){
echo "exiting ..."
kill $SERVER_PID
#gtk "gtk_exit 0"
exit
}
trap 'end' SIGINT
# Start gtk-server
./gtk-server fifo=$PIPE log &
SERVER_PID=$!
Thanks for sharing!
Well it could be meant as another optional layer on top of it for
simplifying some frequent tasks. But if it is easy enough then such
layer is not needed and would add unneeded complexity to gtk-server.
Maybe it is easy to merge the sourcecode of Zenity into the
GTK-server, as I do not want to reinvent the wheel again :-). As an
idea: it could be an option of the 'configure'-script, for example:
./configure --with-zenity
If you run 'make' then GTK-server is compiled together with the
complete functionality of Zenity. I am not sure if this is going to
work though, but I will investigate it.
To resume for the FIFO interface, I will put the default behaviour of
the GTK-server to backgrounding itself while not eating a 100% CPU
(backgrounding is necessary anyway in a script), and I will add the
option that the client script can create the FIFO pipe, instead of the
GTK-server.
By the way, if you are using BASH, please checkout the 'embedded GTK'
concept, which may improve the readability of your code:
http://www.gtk-server.org/embedded.bash
Regards
Peter
- References:
- [gtk-server] busy loop on startup with fifo method
- From: Frantisek Dufka
- [gtk-server] Re: busy loop on startup with fifo method
- From: Peter van Eerten
- [gtk-server] Re: busy loop on startup with fifo method
- From: Frantisek Dufka
- [gtk-server] Re: busy loop on startup with fifo method
- From: Peter van Eerten
- [gtk-server] Re: busy loop on startup with fifo method
- From: Frantisek Dufka
Other related posts:
- » [gtk-server] busy loop on startup with fifo method
- » [gtk-server] Re: busy loop on startup with fifo method
- » [gtk-server] Re: busy loop on startup with fifo method
- » [gtk-server] Re: busy loop on startup with fifo method
- » [gtk-server] Re: busy loop on startup with fifo method
- » [gtk-server] Re: busy loop on startup with fifo method
Ah, I see, it is easy then. Or at least in some situations. I was
thinking about killing gtk-server when there is some error or script is
interrupted via ctrl-c. Just tried it and indeed it doesn't work very
good when hitting ctrl+c. When script is waiting inside gtk
"gtk_server_callback WAIT" and I call another gtk "gtk_exit 0" from
trap handler it does not do the right thing (i.e exit gtk server) it
simply prints error and does nothing
./demo-fifo.sh: 1: cannot create /tmp/gtk-server-fifo.2613: Interrupted
system call
In such cases it may be easier to kill gtk-server directly and the
correct PID is in $! after running gtk-server with & so it is easy.
With gtk server forking to background you would need to hunt it down
via ps and grep. This simple code works as expected
end(){
echo "exiting ..."
kill $SERVER_PID
#gtk "gtk_exit 0"
exit
}
trap 'end' SIGINT
# Start gtk-server
./gtk-server fifo=$PIPE log &
SERVER_PID=$!
Well it could be meant as another optional layer on top of it for simplifying some frequent tasks. But if it is easy enough then such layer is not needed and would add unneeded complexity to gtk-server.
- [gtk-server] busy loop on startup with fifo method
- From: Frantisek Dufka
- [gtk-server] Re: busy loop on startup with fifo method
- From: Peter van Eerten
- [gtk-server] Re: busy loop on startup with fifo method
- From: Frantisek Dufka
- [gtk-server] Re: busy loop on startup with fifo method
- From: Peter van Eerten
- [gtk-server] Re: busy loop on startup with fifo method
- From: Frantisek Dufka