You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to use a pipe to achieve IPC in wasm. However, it seems like fifo is not mapped as a fifo, and I failed to open it.
I am not sure if the fifo type is supported or if I did it wrong.
Here is how I run it:
mkfifo /tmp/fifo
ls /tmp/fifo
>|rw-r--r-- - x 2 May 11:42 /tmp/fifo
clang --target=wasm32-wasi --sysroot=/usr/share/wasi-sysroot -o test_fifo.wasm test_fifo.c
wasmer run --mapdir /tmp:/tmp test_fifo.wasm
> /tmp/fifo is not a FIFO
// test_fifo.c#include<stdio.h>#include<stdlib.h>#include<sys/stat.h>#include<fcntl.h>#include<unistd.h>#include<sys/types.h>#include<sys/stat.h>intmain()
{
constchar*fifo_path="/tmp/fifo";
structstatst;
if (stat(fifo_path, &st) ==-1) {
perror("stat");
exit(EXIT_FAILURE);
}
if (S_ISFIFO(st.st_mode)) {
printf("%s is a FIFO\n", fifo_path);
intfd=open(fifo_path, O_RDONLY);
if (fd==-1) {
perror("open");
exit(EXIT_FAILURE);
}
charbuffer[128];
ssize_tbytes_read;
while ((bytes_read=read(fd, buffer, sizeof(buffer) -1)) >0) {
buffer[bytes_read] ='\0';
printf("Received: %s\n", buffer);
}
if (bytes_read==-1) {
perror("read");
}
close(fd);
} else {
printf("%s is not a FIFO\n", fifo_path);
}
return0;
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I am trying to use a pipe to achieve IPC in wasm. However, it seems like fifo is not mapped as a fifo, and I failed to open it.
I am not sure if the fifo type is supported or if I did it wrong.
Here is how I run it:
Beta Was this translation helpful? Give feedback.
All reactions