Name

mkfifo - makes a FIFO(First In First Out) file

Library

libc.lib

Synopsis

  #include <sys/types.h>
  #include <sys/stat.h>
  int mkfifo (const char *path, mode_t mode);

Return values

The mkfifo function returns the value 0 if successful; otherwise the value -1 is returned and errno is set to indicate the error.

Detailed description

The mkfifo system call creates a new FIFO(First In First Out) file with name path. The access permissions are specified by mode and restricted by the umask of the calling process. With the current implementation, the use of umask has no effect.

The fifo’s owner ID and group ID is set to root.

Please note that running stat on fifo file does not provide modification time information and is set to file creation time. Use fstat (on the fd) instead to retrieve the last modified time.


Examples

#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>

         
int main(void)
{
    char *pathname = "C:\\XXX";
    mode_t mode = 0666;
    if (mkfifo(pathname, mode) == -1) {
        printf("mkfifo() failed\n");
    }
    return 0;
}

         


Errors

The mkfifo system call will fail and no fifo will be created if:
[ENOTDIR]
  A component of the path prefix is not a directory.
[ENAMETOOLONG]
  A component or an entire path name exceeded 255 characters.
[ENOENT]
  A component of the path prefix does not exist.
[EACCES]
  Search permission is denied for a component of the path prefix.
[ELOOP]
  Too many symbolic links were encountered in translating the pathname.
[EROFS]
  The named file resides on a read-only file system.
[EEXIST]
  The named file exists.
[ENOSPC]
  The directory in which the entry for the new fifo is being placed cannot be extended because there is no space left on the file system containing the directory.

See also

chmod, stat, umask

Feedback

For additional information or queries on this page send feedback

© 2005-2007 Nokia

Top