Qp0zPipe()--Create Interprocess Channel with Sockets


  Syntax
 #include <spawn.h>

 int Qp0zPipe(int fildes[2]);  
  Service Program Name: QP0ZSPWN

  Default Public Authority: *USE

  Threadsafe: Yes

The Qp0zPipe() function creates a data pipe that can be used by two processes. One end of the pipe is represented by the file descriptor returned in fildes[0]. The other end of the pipe is represented by the file descriptor returned in fildes[1]. Data that is written to one end of the pipe can be read from the other end of the pipe in a first-in-first-out basis. Both ends of the pipe are open for reading and writing.

The Qp0zPipe() function is often used with the spawn() function to allow the parent and child processes to send data to each other.


Parameters

fildes[2]
(Input) An integer array of size 2 that will contain the pipe descriptors.

Authorities

None.


Return Value

0 Qp0zPipe() was successful.
-1 Qp0zPipe() was not successful. The errno variable is set to indicate the error.


Error Conditions

If Qp0zPipe() is not successful, errno usually indicates one of the following errors. Under some conditions, errno could indicate an error other than those listed here.

Error condition Additional information
[EFAULT]  
[EINVAL]  
[EIO]  
[EMFILE]  
[ENFILE]  
[ENOBUFS]  
[EOPNOTSUPP]  
[EUNKNOWN]  

Usage Notes

The i5/OS implementation of the Qp0zPipe()function is based on sockets rather than pipes and, therefore, uses socket descriptors. There are several differences:

  1. After calling the fstat() function using one of the file descriptors returned on a Qp0zPipe() call, when the st_mode from the stat structure is passed to the S_ISFIFO() macro, the return value indicates FALSE. When the st_mode from the stat structure is passed to S_ISSOCK(), the return value indicates TRUE.

  2. The file descriptors returned on a Qp0zPipe() call can be used with the send(), recv(), sendto(), recvfrom(), sendmsg(), and recvmsg() functions.

  3. If this function is called by a thread executing one of the scan-related exit programs (or any of its created threads), the descriptors that are returned are scan descriptors. See Integrated File System Scan on Open Exit Programs and Integrated File System Scan on Close Exit Programs for more information. If a process is spawned, these scan descriptors are not inherited by the spawned process and therefore cannot be used in that spawned process. Therefore, in this case, the descriptors returned by Qp0zPipe() function will only work within the same process.

If you want to use the traditional implementation of pipes, in which the descriptors returned are pipe descriptors instead of socket descriptors, use the pipe() function.


Related Information



API introduced: V4R1
Top | UNIX-Type APIs | APIs by category