[gtk-server] Re: busy loop on startup with fifo method

  • From: Frantisek Dufka <dufkaf@xxxxxxxxx>
  • To: Peter van Eerten <administrator@xxxxxxxxxxxxxx>
  • Date: Tue, 17 Apr 2007 16:12:23 +0200

Peter van Eerten wrote:

Well, the first method also could involve a change in the syntax of the GTK-server, for example:

gtk-server fifo=/tmp/bla nocreate

If that's OK with you then it's easy indeed.

Yes, that would be fine. Thanks.

With the background forking, you do not need the PID, because the call "gtk_exit" will automatically also exit the GTK-server. Next to this call you can send a plain "gtk_server_exit" as well.

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

echo "exiting ..."
#gtk "gtk_exit 0"

trap 'end' SIGINT

# Start gtk-server
./gtk-server fifo=$PIPE log &

Adding some default dialogs would be contradictory to GTK-server logic, I would say, as it is only a 'gateway' for interpreted languages to the GTK API. But it should be rather easy to write some simple dialogs using the built-in dialogs from GTK, like the GtkAboutDialog, GtkMessageDialog, GtkColorSelectionDialog, GtkFileChooserDialog and so on.

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.


Other related posts: