Hi, I'm not subscribed, please keep me CC'd. In this corner case, errno is unset despite fputs giving an error. I'm on Debian testing using musl-gcc 1.2.1. #define _POSIX_C_SOURCE 200809L #include #include #include int main(void) { FILE *f = fopen("/", "r"); if(f == NULL) { perror("fopen()"); } if(fputs("Hello world\n", f) == EOF) { assert(errno); perror("fputs()"); } } With glibc this prints EBADF for fputs. The wiki page about writing tests [1], which I thought this would be a good candidate for, has the 404 link http://nsz.repo.hu/git/?p=libc-test Please let me know if I can help debugging. [1] https://wiki.musl-libc.org/writing-tests.html