How do I create a named pipe?


To create a named pipe interactively, you'll use either mknod or
mkfifo. On some systems, mknod will be found in /etc. In other
words, it might not be on your path. See your man pages for details.



To make a named pipe within a C program use mkfifo():




/* set the umask explicitly, you don't know where it's been */
umask(0);
if (mkfifo("test_fifo", S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP))
{
perror("mkfifo");
exit(1);
}



If you don't have mkfifo(), you'll have to use mknod():




/* set the umask explicitly, you don't know where it's been */
umask(0);
if (mknod("test_fifo",
S_IFIFO | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
0))
{
perror("mknod");
exit(1);
}




[an error occurred while processing this directive]