Creating a named pipe

To create a UNIX named pipe, use the mknod command on the command line or the mknod() system call from a C program. The two techniques produce the same results. The examples in these topics use the command-line technique.

Once you create a named pipe, its characteristics are similar to an ordinary file. For example, it is located in a directory, has a pathname, and exists until you delete it.

The mknod command has more than one form. This is the syntax for the form that creates a named pipe:

Syntax

mknod named-pipe-identifier p

The named-pipe-identifier is the pathname of the named pipe you want to create.

For example, to create a named pipe called mypipe in the current directory, type the following command:

mknod mypipe p 

The following C function shows how to use the mknod() system call to create a named pipe:

int mkfifo(path) /* make FIFO */
char *path;
{  
  return(mknod(path, S_IFIFO | 0666, 0));
}

For more information on mknod or mknod(), see your UNIX system documentation.