[Gambas-user] Pipe EOF

T Lee Davidson t.lee.davidson at gmail.com
Wed Dec 25 23:18:29 CET 2019


On 12/25/19 1:42 PM, Admin wrote:
> Well... I could have sworn I've seen it yesterday, now I don't, so mabe you are right. Also I now see that there's 
> Process.Closeinput method, that states "This replaces the old behaviour of previous Gambas version when closing the stream with 
> theCLOSE <http://gambaswiki.org/wiki/lang/close>instruction." so that you can't just CLOSE a process handle to send Ctrl-D to a 
> Stream. Maybe I should try this on my Shell "tar ...". Just not yet sure how.

I'm assuming that you are piping the file contents, versus extracting base.tar.gz directly, so that you can keep track of the 
progress.

Perhaps you could use an event handler to transact the packets instead of looping through them. If you open the archive file 
pipe, "For Read Watch", the event handler File_Read() will be triggered if at least one byte can be read from the pipe. Test for 
EOF on the archive pipe and when true, send Ctrl-D to the output and clean up.

Note: Do not use 'Wait' in an event handler.

And also keep in mind that, "Opening a pipe for reading normally blocks until some other process opens the same pipe for 
writing." So, you may want to open that watched pipe after the other setup and even after shelling out to `tar`.


-- 
Lee


More information about the User mailing list