[Date Prev] [Date Index] [Date Next] [Thread Prev] [Thread Index] [Thread Next]

Re: Console taking 100% CPU

Bryan Stansell bryan@conserver.com
Tue, 14 Dec 2010 22:31:02 GMT


I dug back into that code to see where it came from, etc.  There was a
desire to be able to pipe console commands/interaction to the console
client and the code ignores EOF in that case.  So, stuff like "echo
'^[cr^[c.' | console host" can process the input, and then also send out
the output without bailing prematurely.  Why?  Well, in this "batch"
case, you don't want the console client to exit before getting back the
output from the server - and there's no way to tell when the data will
be "done".

I should probably fix it to not chew up all the CPU...but it would still
"hang".  If you can wrap this thing in a pty, the code will detect it as
such and actually close things down on EOF.  Or adjust the 'screwy'
(yeah, pleasant name) variable in console.c so it is always 1 - pretends
all connections are pty-based.

Bryan

On Dec 14, 2010, at 1:59 PM, Chris Fowler wrote:

> On Tue, 2010-12-14 at 16:54 -0500, Chris Marget wrote:
>> read(0, "", 8192)                       = 0
>> select(4, [0 3], [], NULL, NULL)        = 1 (in [0])
>> read(0, "", 8192)                       = 0
>> select(4, [0 3], [], NULL, NULL)        = 1 (in [0])
>> read(0, "", 8192)                       = 0 
> 
> select() has seen STDIN ready to be read.
> read() reads 0 bytes.  This is an EOF condition.
> 
> Easy.  Fix the code so that when reading from 0 if 0 bytes are read is
> restores the terminal and exits.
> 
> 
> _______________________________________________
> users mailing list
> users@conserver.com
> https://www.conserver.com/mailman/listinfo/users