Version of emscripten/emsdk:
After closing the write end of a pipe(), read() on the read end should return 0 to signal EOF. Under Emscripten it returns -1 with errno=EAGAIN, potentially breaking pipe-based producer/consumer loop that waits for EOF.
Failing command line in full:
$ emcc -O0 -Wall pipe_eof.c -o a.out.js
$ node a.out.js
read(pipe_read after close_write): ret=-1 errno=6
The same program on native Linux prints read(pipe_read after close_write): ret=0 errno=0.
Example code snippet:
#include <unistd.h>
#include <stdio.h>
#include <errno.h>
int main(void) {
int pipefd[2];
char buf[16];
pipe(pipefd);
close(pipefd[1]); // close write end
errno = 0;
ssize_t r = read(pipefd[0], buf, sizeof(buf));
printf("read(pipe_read after close_write): ret=%zd errno=%d\n", r, errno);
close(pipefd[0]);
return (r == 0) ? 0 : 1;
}
Version of emscripten/emsdk:
After closing the write end of a
pipe(),read()on the read end should return0to signal EOF. Under Emscripten it returns-1witherrno=EAGAIN, potentially breaking pipe-based producer/consumer loop that waits for EOF.Failing command line in full:
The same program on native Linux prints
read(pipe_read after close_write): ret=0 errno=0.Example code snippet: