Rtems telnetd/shell question (and Why does fgetc() return 0 for a 0-length socket read?)
Chris Johns
chrisj at rtems.org
Fri Oct 30 03:16:19 UTC 2009
Peter Dufault wrote:
>
> On Oct 28, 2009, at 6:11 , Chris Johns wrote:
>
>> I suspect we need to handle a read of the fd better. Closing a remote
>> end of a socket always returns a length of 0. I do not know how this
>> is handled with fget.
>
> I'm just sitting down to look a this, and the first thing I'm asking is
> how can fgetc() return 0 when the socket it is buffering returns a 0
> length read? Since 0 is a valid return for fgetc() this doesn't make
> any sense. I don't have too much time to write test programs right now
> so I'm throwing out this question: can fgetc() return 0 for a zero
> length read on an underlying socket, or is there a new lower-level bug
> that is screwing things up?
>
> The fgetc() man page isn't clear and I didn't come up with an internet
> search to get the answer.
We could always remove the fgetc call and use read but the user command
handlers could have the same problem if they read from stdin.
I am wondering if this is a bug in newlib and should be fixed.
Regards
Chris
More information about the users
mailing list