Reading from FIFO after unlink()
问题 I have created a FIFO, wrote to it and unlinked it. To my surprise I was able to read data from the fifo after unlinking, why is that? #include <fcntl.h> #include <sys/stat.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/wait.h> #define MAX_BUF 256 int main() { int fd; char * myfifo = "/tmp/myfifo"; /* create the FIFO (named pipe) */ mkfifo(myfifo, 0666); int pid = fork(); if (pid != 0) { /* write "Hi" to the FIFO */ fd = open(myfifo, O_WRONLY); write(fd, "Hi",