[Gambas-user] Opening Pipes (avoiding lockup)

Bruce Steers bsteers4 at gmail.com
Sat Oct 3 20:55:38 CEST 2020

Hi all.
I just uploaded a simple pipe opening/watching routing to the Application
section as an example.
The reason for this was because it took me quite some time to figure out
how to get a pipe working at first and thought many others may have hit the
same brick wall. It seemed EVERYTHING I tried just locked up the app til
the pipe got some text sent, then everything was okay, the app could run
and the File_Read() event would trigger on any more text sent as expected.

What was not expected is that "Opening" the pipe is like calling a Read
method that locks the program till it gets some text.
I came up with a simple solution (eventually) to use the Shell command to
echo a blank line to the pipe just before opening it...

 Shell "echo '' >/tmp/FIFO1"
 hFile = Pipe "/tmp/FIFO1" For Read Watch

That way when the pipe opens it gets the echo and moves on so the program
continues running.
It just seemed wrong though.
Like either i was doing something wrong in how i was opening the pipe or it
was a bug in the pipe opening call?
I would have thought that setting the "Watch" option would open the pipe
without expecting text and just set up the Read event and move on.

I found using "Read Write Watch" all together and setting Blocking to False
Allowed the program to move past the open without sending text but that
gave me weird errors like pop-up menus stopped triggering Click() events, I
had some menus visible in the menubar AND attached to a button popup and
got the click event okay from the top menu but got nothing from the popup
menus. If i removed the "Write" from the pipe opening call the popups
worked again!?
I found the Shell "echo" method the best way but like i say , seems wrong
to have to do it that way.

Thanks all :)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20201003/8dd7459f/attachment.htm>

More information about the User mailing list