[Gambas-user] Why 100% CPU load on file OPEN with WATCH if data comes from a pipe ?

Peter Bauer pebauer68 at gmail.com
Wed Feb 19 00:10:42 CET 2020


Hello,
Gambas 3.14, When piping like this: (program listing is on the end !)
>echo ABC | ./input_reader.gambas     /* pipe just 3 chars
I see permanent 100% CPU load(with top) on Ubuntu 18.04.01.
When using from terminal like this, there is no high CPU load:
>$./input_reader.gambas
>ABC    /* type some text on the terminal

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,
Peter

Listing ./input_reader.gambas:
' Gambas class file

Static Public hFile1 As Stream
Static Public sline As String

Public Sub Form_Open()
hFile1 = Open "/dev/stdin" For Input Watch
hFile1.Blocking = False
End

Public Sub Form_Close()
  hFile1.close
End

Public Sub File_Read()                          ' File Read event handler
     While Not Eof(hFile1)
         Line Input #hFile1, sLine
         TextArea1.Insert(sLine & gb.NewLine)
         Wend
End

Public Sub Timer1_Timer()       'with 100 ms
   TextArea1.EnsureVisible()
     TextArea1.Refresh
End
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gambas-basic.org/pipermail/user/attachments/20200219/2b8ddd56/attachment.html>


More information about the User mailing list