From 9ac8ffc564e007f64465f2ae2d345f55df20fad4 Mon Sep 17 00:00:00 2001 From: patacongo Date: Fri, 3 Jun 2011 15:38:26 +0000 Subject: [PATCH] Fix a nasty bug that was closing stdin git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3663 42af7a65-404d-4744-a932-0658087f49c3 --- lib/stdio/lib_fgets.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/stdio/lib_fgets.c b/lib/stdio/lib_fgets.c index 3f72f00005..ce2aa9476d 100644 --- a/lib/stdio/lib_fgets.c +++ b/lib/stdio/lib_fgets.c @@ -97,7 +97,10 @@ static const char g_erasetoeol[] = "\033[K"; static inline int _lib_rawgetc(int fd) { char buffer; - if (read(fd, &buffer, 1) < 1) + ssize_t nread; + + nread = read(fd, &buffer, 1); + if (nread < 1) { /* Return EOF if the end of file (0) or error (-1) occurs */