Version of emscripten/emsdk:
ioctl(pipe_read, FIONREAD, &avail) should return 0 and set avail to the byte count buffered in the pipe. Under Emscripten it returns 28 and leaves avail = 0 even when the pipe has data ready to read.
Failing command line in full:
$ emcc -O0 -Wall fionread.c -o a.out.js
$ node a.out.js
FIONREAD: ret=28 avail=0
The same program on native Linux prints FIONREAD: ret=0 avail=5.
Example code snippet:
#include <unistd.h>
#include <sys/ioctl.h>
#include <stdio.h>
int main(void) {
int pfd[2];
pipe(pfd);
write(pfd[1], "hello", 5);
int avail = 0;
int r = ioctl(pfd[0], FIONREAD, &avail);
printf("FIONREAD: ret=%d avail=%d\n", r, avail);
close(pfd[0]); close(pfd[1]);
return (r == 0 && avail == 5) ? 0 : 1;
}
Version of emscripten/emsdk:
ioctl(pipe_read, FIONREAD, &avail)should return0and setavailto the byte count buffered in the pipe. Under Emscripten it returns28and leavesavail = 0even when the pipe has data ready to read.Failing command line in full:
The same program on native Linux prints
FIONREAD: ret=0 avail=5.Example code snippet: