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

  • From: Frantisek Dufka <dufkaf@xxxxxxxxx>
  • To: gtk-server@xxxxxxxxxxxxx
  • Date: Mon, 16 Apr 2007 17:22:53 +0200


I tried gtk-server from busybox shell and since it doesn't support |& two-way pipe method the second best method to use seems to be FIFO.

The only clumsy thing is waiting for the fifo to be created at startup. The bash example runs gtk-server via & and then busy loops waiting for fifo file to appear while burning CPU (forking true command) and slowing gtk-server startup.

# Start gtk-server
gtk-server fifo=$PIPE log &
# Wait for the server to initialize
while [ ! -p $PIPE ]; do true; done

I tried to make fifo if advance but gtk-server doesn't like it. Since there is also no sleep shell command with milisecond precision there is no easy way to wait without burning CPU.

It would be nice to have some functionality helping with this. Some ideas:

1. Fork gtk-server to background after fifo is created so you could use something like

gtk-server fifo=$PIPE log detach
gtk "gtk_init NULL NULL"

2. Allow gtk-server to use pre-created fifo file (via mkfifo) so client doesn't need to loop waiting for file to appear.

mkfifo $PIPE
gtk-server fifo=$PIPE log &
gtk "gtk_init NULL NULL"

I tried to simply comment out Print_Error on line 2926
//Print_Error("%s%s", 2, "Could not create FIFO! ERROR: ",strerror(errno)); and it works exactly as expected solving this problem. Is there some reason why this is not a good idea?

Or is there some easy way to wait for fifo file to appear without busy loop? Thanks a lot and thanks for gtk-server.


Other related posts: