Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mkfifo() and mknod() create regular file with NODERAWFS=1 #16158

Open
tiran opened this issue Jan 31, 2022 · 1 comment
Open

mkfifo() and mknod() create regular file with NODERAWFS=1 #16158

tiran opened this issue Jan 31, 2022 · 1 comment

Comments

@tiran
Copy link
Contributor

tiran commented Jan 31, 2022

I noticed that mkfifo and mknod both create an empty regular file instead of a fifo.

Version of emscripten/emsdk:

emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.1 (1934a98e709b57d3592b8272d3f1264a72c089e4)
clang version 14.0.0 (https://github.com/llvm/llvm-project f142c45f1e494f8dbdcc1bcf14122d128ac8f3fe)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /emsdk/upstream/bin

reproducer

#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>

int main(void)
{
    unlink("testfifo");
    mkfifo("testfifo", 0644);
    return 0;
}
$ gcc -o mkfifo mkfifo.c && ./mkfifo
$ stat -c %F testfifo 
fifo

$ strace -P testfifo ./mkfifo
strace: Requested path 'testfifo' resolved into '/python-wasm/cpython/builddir/testfifo'
unlink("testfifo")                      = 0
mknod("testfifo", S_IFIFO|0644)         = 0
+++ exited with 0 +++
$ emcc -s NODERAWFS=1 -o mkfifo.js mkfifo.c && node ./mkfifo.js
$ stat -c %F testfifo 
regular empty file

$ strace -P testfifo node ./mkfifo.js
strace: Requested path 'testfifo' resolved into '/python-wasm/cpython/builddir/testfifo'
unlink("testfifo")                      = 0
openat(AT_FDCWD, "testfifo", O_WRONLY|O_CREAT|O_TRUNC|O_CLOEXEC, 010644) = 17
close(17)                               = 0
+++ exited with 0 +++
@algestam
Copy link
Contributor

Seems like that the nodejs fs module lacks support for creating fifos (nodejs/node#38344).

The NODERAWFS implementation of the mknod function calls the fs.writeFileSync function which causes the file to be created instead of a fifo.

From what I understand, it will not be possible to create fifo pipes until support for this has been added to nodejs. Is that right or do I miss something?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants