1. Create a FIFO
umask (0);
mknod("/tmp/MYFIFO", S_IFIFO|0666, 0);
2. Open a FIFO
fd = open ("/tmp/MYFIFO", O_WRONLY);
fd = open ("tmp/MYFIFO", O_RDONLY|O_NDELAY);
3. Read/Write FIFO
if (read (fd, msgbuf, MSGSIZE+1) < 0)
perror ("Message read failed!");
if ((nwrite = write (fd, msgbuf, MSGSIZE+1)) <= 0)
{
if (nwrite == 0) /* FIFO is full */
perror ("write");
}
4. Close FIFO
close (fd);
umask (0);
mknod("/tmp/MYFIFO", S_IFIFO|0666, 0);
2. Open a FIFO
fd = open ("/tmp/MYFIFO", O_WRONLY);
fd = open ("tmp/MYFIFO", O_RDONLY|O_NDELAY);
3. Read/Write FIFO
if (read (fd, msgbuf, MSGSIZE+1) < 0)
perror ("Message read failed!");
if ((nwrite = write (fd, msgbuf, MSGSIZE+1)) <= 0)
{
if (nwrite == 0) /* FIFO is full */
perror ("write");
}
4. Close FIFO
close (fd);