[UP]


Manual Reference Pages  - system_mkfifo (3)

NAME

system_mkfifo(3f) - [M_system:FILE_SYSTEM] make a FIFO special file relative to directory file descriptor (LICENSE:PD)

CONTENTS

Synopsis
Description
Return Value
Examples
Author
License

SYNOPSIS

function system_mkfifo(pathname,mode) result(ierr)

   character(len=*),intent(in)       :: pathname
   integer,intent(in)                :: mode
   integer :: ierr

DESCRIPTION

A regular pipe can only connect two related processes. It is created by a process and will vanish when the last process closes it.

A named pipe, also called a FIFO for its behavior, can be used to connect two unrelated processes and exists independently of the processes; meaning it can exist even if no one is using it. A FIFO is created using the mkfifo() library function.

The mkfifo() function creates a new FIFO special file named by the pathname.

The file permission bits of the new FIFO are initialized from mode.

The file permission bits of the mode argument are modified by the process’ file creation mask.

When bits in mode other than the file permission bits are set, the effect is implementation-defined.

If path names a symbolic link, mkfifo() shall fail and set errno to [EEXIST].

The FIFO’s user ID will be set to the process’ effective user ID.

The FIFO’s group ID shall be set to the group ID of the parent directory or to the effective group ID of the process.

Implementations shall provide a way to initialize the FIFO’s group ID to the group ID of the parent directory.

Implementations may, but need not, provide an implementation-defined way to initialize the FIFO’s group ID to the effective group ID of the calling process.

Upon successful completion, mkfifo() shall mark for update the last data access, last data modification, and last file status change timestamps of the file.

Also, the last data modification and last file status change timestamps of the directory that contains the new entry shall be marked for update.

Predefined variables are typically used to set permission modes.

You can bytewise-OR together these variables to create the most common permissions mode:

    User:    R_USR  (read),  W_USR  (write),  X_USR(execute)
    Group:   R_GRP  (read),  W_GRP  (write),  X_GRP(execute)
    Others:  R_OTH  (read),  W_OTH  (write),  X_OTH(execute)

Additionally, some shortcuts are provided (basically a bitwise-OR combination of the above):

     Read + Write + Execute: RWX_U (User), RWX_G (Group), RWX_O (Others)
     DEFFILEMODE: Equivalent of 0666 =rw-rw-rw-
     ACCESSPERMS: Equivalent of 0777 = rwxrwxrwx

Therefore, to give only the user rwx (read+write+execute) rights whereas group members and others may not do anything, you can use any of the following mkfifo() calls equivalently:

     ierr= mkfifo("myfile", IANY([R_USR, W_USR, X_USR]));
     ierr= mkfifo("myfile", RWX_U);

In order to give anyone any rights (mode 0777 = rwxrwxrwx), you can use any of the following calls equivalently:

     ierr= mkfifo("myfile",IANY([R_USR,W_USR,X_USR,R_GRP,W_GRP,X_GRP,R_OTH,W_OTH,X_OTH]));
     ierr= mkfifo("myfile",IANY([RWX_U,RWX_G,RWX_O]));
     ierr= mkfifo("myfile",ACCESSPERMS);

RETURN VALUE

Upon successful completion, return 0. Otherwise, return -1 and set errno to indicate the error. If -1 is returned, no FIFO is created.

EXAMPLES

The following example shows how to create a FIFO file named /home/cnd/mod_done, with read/write permissions for owner, and with read permissions for group and others.

   program demo_system_mkfifo
   use M_system, only : system_mkfifo, system_perror
   !use M_system, only : R_GRP,R_OTH,R_USR,RWX_G,RWX_O
   !use M_system, only : RWX_U,W_GRP,W_OTH,W_USR,X_GRP,X_OTH,X_USR
   !use M_system, only : DEFFILEMODE, ACCESSPERMS
   use M_system, only : W_USR, R_USR, R_GRP, R_OTH
   implicit none
      integer :: status
      status = system_mkfifo("/tmp/buffer", IANY([W_USR, R_USR, R_GRP, R_OTH]))
      if(status.ne.0)then
         call system_perror(’*mkfifo* error:’)
      endif
   end program demo_system_mkfifo

Now some other process (or this one) can read from /tmp/buffer while this program is running or after, consuming the data as it is read.

AUTHOR

John S. Urban

LICENSE

Public Domain


system_mkfifo (3) March 11, 2021
Generated by manServer 1.08 from 95898ec0-30a4-4689-9ce6-b7cdd496beb1 using man macros.