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

Peter Bauer pebauer68 at gmail.com
Wed Feb 19 07:34:23 CET 2020


Von: Peter Bauer <pebauer68 at gmail.com>
Date: Mi., 19. Feb. 2020 um 00:10 Uhr
Subject: RE: Why 100% CPU load on file OPEN with WATCH if data comes from a
pipe ?
To: <user at lists.gambas-basic.org>
Please find the project attached.

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/036ee6e9/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: input_reader.tar.gz
Type: application/gzip
Size: 13242 bytes
Desc: not available
URL: <https://lists.gambas-basic.org/pipermail/user/attachments/20200219/036ee6e9/attachment-0001.gz>


More information about the User mailing list