ibm-information-center/dist/eclipse/plugins/i5OS.ic.apis_5.4.0.1/pipe.htm

259 lines
7.2 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Copyright" content="Copyright (c) 2006 by IBM Corporation">
<title>Qp0zPipe()--Create Interprocess Channel with Sockets</title>
<!-- Begin Header Records ========================================== -->
<!-- All rights reserved. Licensed Materials Property of IBM -->
<!-- US Government Users Restricted Rights -->
<!-- Use, duplication or disclosure restricted by -->
<!-- GSA ADP Schedule Contract with IBM Corp. -->
<!-- Change History: -->
<!-- YYMMDD USERID Change description -->
<!-- UNIX11 SCRIPT A converted by B2H R4.1 (346) (CMS) by V2DCIJB at -->
<!-- RCHVMW2 on 1 Jun 1999 at 16:14:12 -->
<!-- Edited by Kersten Feb 02 -->
<!-- 020530 JTROUS Changes for Virus scanner, 98860, V5R3 -->
<!-- 0206?? JET This file has undergone html cleanup -->
<!-- 050404 JTROUS: fix enums, no change flag, V5R4 -->
<!-- End Header Records -->
<link rel="stylesheet" type="text/css" href="../rzahg/ic.css">
</head>
<body>
<!-- Java sync-link -->
<script language="Javascript" src="../rzahg/synch.js" type="text/javascript">
</script>
<a name="Top_Of_Page"></a>
<h2>Qp0zPipe()--Create Interprocess Channel with Sockets</h2>
<div class="box" style="width: 60%;">
<br>
&nbsp;&nbsp;Syntax<br>
<pre>
#include &lt;spawn.h&gt;
int Qp0zPipe(int <em>fildes[2]</em>);
</pre>
&nbsp;&nbsp;Service Program Name: QP0ZSPWN<br>
<!-- iddvc RMBR -->
<br>
&nbsp;&nbsp;Default Public Authority: *USE<br>
<!-- iddvc RMBR -->
<br>
&nbsp;&nbsp;Threadsafe: Yes<br>
<!-- iddvc RMBR -->
<br>
</div>
<p>The <strong>Qp0zPipe()</strong> 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 <em>fildes[0]</em>. The other end of the pipe is
represented by the file descriptor returned in <em>fildes[1]</em>. 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.</p>
<p>The <strong>Qp0zPipe()</strong> function is often used with the <strong>
spawn()</strong> function to allow the parent and child processes to send data
to each other.</p>
<br>
<h3>Parameters</h3>
<dl>
<dt><strong><em>fildes[2]</em></strong></dt>
<dd>(Input) An integer array of size 2 that will contain the pipe
descriptors.</dd>
</dl>
<br>
<h3>Authorities</h3>
<p>None.</p>
<br>
<h3>Return Value</h3>
<table cellpadding="5">
<!-- cols="5 95" -->
<tr>
<td align="left" valign="top"><em>0</em></td>
<td align="left" valign="top"><strong>Qp0zPipe()</strong> was successful.</td>
</tr>
<tr>
<td align="left" valign="top"><em>-1</em></td>
<td align="left" valign="top"><strong>Qp0zPipe()</strong> was not successful.
The <em>errno</em> variable is set to indicate the error.</td>
</tr>
</table>
<br>
<br>
<h3>Error Conditions</h3>
<p>If <strong>Qp0zPipe()</strong> is not successful, <em>errno</em> usually
indicates one of the following errors. Under some conditions, <em>errno</em>
could indicate an error other than those listed here.</p>
<table cellpadding="5">
<!-- cols="25 75" -->
<tr>
<th align="left" valign="bottom">Error condition</th>
<th align="left" valign="bottom">Additional information</th>
</tr>
<tr>
<td align="left" valign="top">
<em>[<a href="unix14.htm#EFAULT">EFAULT</a>]</em></td>
<td align="left" valign="top">
&nbsp;
</td>
</tr>
<tr>
<td align="left" valign="top">
<em>[<a href="unix14.htm#EINVAL">EINVAL</a>]</em></td>
<td align="left" valign="top">
&nbsp;
</td>
</tr>
<tr>
<td align="left" valign="top">
<em>[<a href="unix14.htm#EIO">EIO</a>]</em></td>
<td align="left" valign="top">
&nbsp;
</td>
</tr>
<tr>
<td align="left" valign="top">
<em>[<a href="unix14.htm#EMFILE">EMFILE</a>]</em></td>
<td align="left" valign="top">
&nbsp;
</td>
</tr>
<tr>
<td align="left" valign="top">
<em>[<a href="unix14.htm#ENFILE">ENFILE</a>]</em></td>
<td align="left" valign="top">
&nbsp;
</td>
</tr>
<tr>
<td align="left" valign="top">
<em>[<a href="unix14.htm#ENOBUFS">ENOBUFS</a>]</em></td>
<td align="left" valign="top">
&nbsp;
</td>
</tr>
<tr>
<td align="left" valign="top"><em>[<a href="unix14.htm#EOPNOTSUPP">EOPNOTSUPP</a>]</em></td>
<td align="left" valign="top">
&nbsp;
</td>
</tr>
<tr>
<td align="left" valign="top">
<em>[<a href="unix14.htm#EUNKNOWN">EUNKNOWN</a>]</em></td>
<td align="left" valign="top">
&nbsp;
</td>
</tr>
</table>
<br>
<h3><a name="USAGE_NOTES">Usage Notes</a></h3>
<p>The i5/OS implementation of the <strong>Qp0zPipe()</strong>function is
based on sockets rather than pipes and, therefore, uses socket descriptors.
There are several differences:</p>
<ol>
<li><p>After calling the <strong>fstat()</strong> function using one of the file
descriptors returned on a Qp0zPipe() call, when the <samp>st_mode</samp> from
the <samp>stat</samp> structure is passed to the S_ISFIFO() macro, the return
value indicates FALSE. When the <samp>st_mode</samp> from the <samp>stat</samp>
structure is passed to S_ISSOCK(), the return value indicates TRUE.</p></li>
<li><p>The file descriptors returned <strong>on a Qp0zPipe()</strong> call can be
used with the <strong>send()</strong>, <strong>recv()</strong>, <strong>
sendto()</strong>, <strong>recvfrom()</strong>, <strong>sendmsg()</strong>, and
<strong>recvmsg()</strong> functions.</p></li>
<li>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
<a href="ifsopenexit.htm">Integrated File System Scan on Open Exit Programs</a>
and <a href="ifscloseexit.htm">Integrated File System Scan on Close Exit
Programs</a> 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 <strong>Qp0zPipe()</strong> function will only work within the same process.
</li>
</ol>
<p>If you want to use the traditional implementation of pipes, in which the
descriptors returned are pipe descriptors instead of socket descriptors, use
the <strong>pipe()</strong> function.</p>
<br>
<h3>Related Information</h3>
<ul>
<li>The &lt;<strong>spawn.h</strong>&gt; file (see <a href="unix13.htm">Header
Files for UNIX-Type Functions</a>)
</li>
<li><a href="fstat.htm">fstat()</a>--Get File Information by Descriptor
</li>
<li><a href="pipe2.htm">pipe()</a>--Create an Interprocess Channel
</li>
<li><a href="spawn.htm">spawn()</a>--Spawn Process
</li>
<li><a href="socketp.htm">socketpair()</a>--Create a Pair of Sockets
</li>
<li><a href="stat.htm">stat()</a>--Get File Information</li>
</ul>
<br>
<hr>
API introduced: V4R1
<hr>
<center>
<table cellpadding="2" cellspacing="2">
<tr align="center">
<td valign="middle" align="center"><a href="#Top_Of_Page">Top</a> | <a href=
"unix.htm">UNIX-Type APIs</a> | <a href="aplist.htm">APIs by category</a></td>
</tr>
</table>
</center>
</body>
</html>