mkfifo()

Создать особый FIFO-файл

Прототип:

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

Аргументы:

path
The pathname that you want to use for the FIFO special file.
mode
The file permission bits for the new FIFO. For more information, see Access permissions.

Библиотека:

libc

Описание:

The mkfifo() function creates a new FIFO special file named by the pathname pointed to by path. The file permission bits of the new FIFO are initialized from mode, modified by the process's creation mask (see umask()). Bits that are set in mode other than the file permission bits are ignored.

The FIFO owner ID is set to the process's effective user ID and the FIFO's group ID is set to the process's effective group ID.

If mkfifo() succeeds, the st_ftime, st_ctime, st_atime and st_mtime fields of the file are marked for update. Also, the st_ctime and st_mtime fields of the directory that contains the new entry are marked for update.

Возвращаемое значение:

0
Успешное завершение.
-1
Возникла ошибка. Код ошибки записан в errno.

Коды ошибок:

EACCES
A component of the path prefix denies search permission.
EEXIST
The named file already exists.
ENAMETOOLONG
The length of the path string exceeds PATH_MAX, or a pathname component is longer than NAME_MAX.
ENOENT
A component of the path prefix doesn't exist, or the path arguments points to an empty string.
ENOSPC
The directory that would contain the new file cannot be extended, or the filesystem is out of file allocation resources (that is, the disk is full).
ENOSYS
This function isn't supported for this path.
ENOTDIR
A component of the path prefix isn't a directory.
EROFS
The named file resides on a read-only filesystem.

Примеры:

#include <sys/types.h>
#include <sys/stat.h>
#include <stdlib.h>
int main( void )
{
(void)mkfifo( "hd/kpda", S_IRUSR | S_IWUSR );
return (EXIT_SUCCESS);
}

Классификация:

POSIX 1003.1

Точка остановки потока
Нет
Обработчик прерываний
Нет
Обработчик сигналов
Да
В потоке
Да

Тематические ссылки:

struct stat, chmod(), errno, mknod(), pipe(), stat(), umask()




Предыдущий раздел: Описание API системной библиотеки