mkfifo Command

Purpose

Makes first-in-first-out (FIFO) special files.

Syntax

mkfifo [ -m Mode ] File ...

Description

The mkfifo command creates FIFO special files specified by the File parameter, in the order specified. If the -m Mode flag is not specified, the file mode of the FIFO file is the bitwise inclusive OR of the S_IRUSR, S_IWUSR, S_IRGRP, S_IWGRP, S_IROTH, and S_IWOTH permissions as modified by the file mode creation (see the umask command).

The mkfifo command functions similarly to the mkfifo subroutine.

Flags

Item Description
-m Mode Sets the file permission bits of the newly created FIFO file to the specified mode values. The Mode variable is the same as the mode operand defined for the chmod command. The characters + (plus sign) and - (minus sign), if used, are interpreted relative to the initial value a=rw (that is, having permissions of rw-rw-rw-).

Exit Status

This command returns the following exit values:

Item Description
0 All the specified FIFO special files were created successfully.
>0 An error occurred.

Examples

  1. To create a FIFO special file with permissions prw-r—r—, enter:

    mkfifo  -m 644 /tmp/myfifo

    This command creates the /tmp/myfifo file with read/write permissions for the owner and read permission for the group and for others.
  2. To create a FIFO special file using the - (minus sign) operand to set permissions of prw-r——-, enter:

    mkfifo  -m g-w,o-rw /tmp/fifo2

    This command creates the /tmp/fifo2 file, removing write permission for the group and all permissions for others.
    Note: If more than one file is created using the - (minus sign) operand, separate each mode specifier with a comma and no spaces.

Files

Item Description
/usr/bin/mkfifo Contains the mkfifo command.