Closed
Description
Setup:
mkdir has_named_pipe
mkfifo has_named_pipe/named_pipe
File a.c
:
#include <sys/types.h>
#include <dirent.h>
#include <stdio.h>
#ifdef __EMSCRIPTEN__
#include <emscripten.h>
#endif
int count_entries(char* dirname) {
DIR* d = opendir(dirname);
struct dirent *ep;
int res = 0;
while (1) {
ep = readdir(d);
if (ep == NULL) {
break;
}
res ++;
printf("%s\n", ep->d_name);
}
return res;
}
int main() {
#ifdef __EMSCRIPTEN__
EM_ASM({
FS.mount(NODEFS, { root: 'has_named_pipe' }, 'has_named_pipe');
});
#endif
int nentries = count_entries("has_named_pipe");
printf("nentries: %d\n", nentries);
return 0;
}
If we compile and run with gcc we get:
$ gcc a.c
$ ./a.out
named_pipe
.
..
nentries: 3
If we compile and run with emcc we get:
$ emcc a.c -lnodefs.js
$ node a.out.js
nentries: 0
Indeed after we see the named pipe, getdents
stops reading. An error is thrown here: https://github.com/emscripten-core/emscripten/blob/main/src/library_nodefs.js?plain=1#L71 which aborts the normal handling. I think we can just ignore these entries?
Version of emscripten/emsdk:
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.72-git (b2ced9de42ea8028233d7d3588c45ce837b61185)
clang version 20.0.0git (https:/github.com/llvm/llvm-project 50866e84d1da8462aeb96607bf6d9e5bbd5869c5)
Target: wasm32-unknown-emscripten
Thread model: posix
Metadata
Metadata
Assignees
Labels
No labels