<div dir="ltr"><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Von: <strong class="gmail_sendername" dir="auto">Peter Bauer</strong> <span dir="auto"><<a href="mailto:pebauer68@gmail.com">pebauer68@gmail.com</a>></span><br>Date: Mi., 19. Feb. 2020 um 00:10 Uhr<br>Subject: RE: Why 100% CPU load on file OPEN with WATCH if data comes from a pipe ?<br>To: <<a href="mailto:user@lists.gambas-basic.org">user@lists.gambas-basic.org</a>><br></div>Please find the project attached.<br><br><div dir="ltr">Hello,<br>Gambas 3.14, When piping like this: (program listing is on the end !)<div>>echo ABC | ./input_reader.gambas /* pipe just 3 chars</div><div>I see permanent 100% CPU load(with top) on Ubuntu 18.04.01.<br>When using from terminal like this, there is no high CPU load:<br>>$./input_reader.gambas<br>>ABC /* type some text on the terminal<br><br>So for the moment it does not make sense to use the File_Read() event handler with piped input. Could it be a problem with WATCH ? To reproduce please build with "make executable" and then run from the terminal. I do not see the problem when running from the Gambas IDE. Is there a workaround ?<br><br>BR,<br>Peter<br><br>Listing ./input_reader.gambas:<br>' Gambas class file<br><br>Static Public hFile1 As Stream<br>Static Public sline As String<br><br>Public Sub Form_Open()<br>hFile1 = Open "/dev/stdin" For Input Watch <br>hFile1.Blocking = False <br>End<br><br>Public Sub Form_Close()<br> hFile1.close<br>End<br> <br>Public Sub File_Read() ' File Read event handler <br> While Not Eof(hFile1) <br> Line Input #hFile1, sLine<br> TextArea1.Insert(sLine & gb.NewLine)<br> Wend<br>End<br><br>Public Sub Timer1_Timer() 'with 100 ms<br> TextArea1.EnsureVisible()<br> TextArea1.Refresh<br>End<br></div></div>
</div></div>