We were checking errno for every non-zero return, instead of every negative return. It's possible that the kernel spuriously sets errno but doesn't return -1, in which case the user should not look at errno. Likewise, an application could have set errno = EPIPE.
And thanks to mtaufen for spotting the typo in read.c. Rebuild glibc, but it's not urgent. Signed-off-by: Barret Rhoden <[email protected]> --- tools/compilers/gcc-glibc/glibc-2.19-akaros/sysdeps/akaros/read.c | 2 +- tools/compilers/gcc-glibc/glibc-2.19-akaros/sysdeps/akaros/write.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/compilers/gcc-glibc/glibc-2.19-akaros/sysdeps/akaros/read.c b/tools/compilers/gcc-glibc/glibc-2.19-akaros/sysdeps/akaros/read.c index 96d3683e772f..771657780623 100644 --- a/tools/compilers/gcc-glibc/glibc-2.19-akaros/sysdeps/akaros/read.c +++ b/tools/compilers/gcc-glibc/glibc-2.19-akaros/sysdeps/akaros/read.c @@ -22,7 +22,7 @@ #include <stddef.h> #include <ros/syscall.h> -/* Write NBYTES of BUF to FD. Return the number written, or -1. */ +/* Read NBYTES of FD to buf. Return the number read, or -1. */ ssize_t __libc_read (int fd, void *buf, size_t nbytes) { diff --git a/tools/compilers/gcc-glibc/glibc-2.19-akaros/sysdeps/akaros/write.c b/tools/compilers/gcc-glibc/glibc-2.19-akaros/sysdeps/akaros/write.c index 9d44807b65b7..248b03a1692b 100644 --- a/tools/compilers/gcc-glibc/glibc-2.19-akaros/sysdeps/akaros/write.c +++ b/tools/compilers/gcc-glibc/glibc-2.19-akaros/sysdeps/akaros/write.c @@ -33,7 +33,7 @@ ssize_t __libc_write(int fd, const void *buf, size_t nbytes) { int ret = ros_syscall(SYS_write, fd, buf, nbytes, 0, 0, 0); - if (unlikely((ret != 0) && (errno == EPIPE))) { + if (unlikely((ret < 0) && (errno == EPIPE))) { sigset_t mask; sigprocmask(0, NULL, &mask); -- 2.8.0.rc3.226.g39d4020 -- You received this message because you are subscribed to the Google Groups "Akaros" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. For more options, visit https://groups.google.com/d/optout.
