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

208 lines
6.0 KiB
HTML
Raw Normal View History

2024-04-02 14:02:31 +00:00
<!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>fork400()--Create a New Process With i5/OS PASE Options</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 -->
<!-- Created by wrmadden on 04 Apr 2003 --><!--End Header Records -->
<link rel="stylesheet" type="text/css" href="../rzahg/ic.css">
</head>
<body>
<!-- Java sync-link -->
<script type="text/javascript" language="Javascript" src="../rzahg/synch.js">
</script>
<a name="Top_Of_Page"></a>
<h2>fork400()and f_fork400()--Create A New Process with i5/OS PASE Options</h2>
<div class="box" style="width: 70%;">
<br>
<br>
&nbsp;&nbsp;Syntax
<pre>
#include &lt;as400_protos.h&gt;
pid_t fork400(const char *<em>jobname</em>,
unsigned int <em>resourceID</em>);
pid_t f_fork400(const char *<em>jobname</em>,
unsigned int <em>resourceID</em>);
</pre>
<br>
&nbsp;&nbsp;Default Public Authority: *USE<br>
<!-- iddvc RMBR -->
<br>
&nbsp;&nbsp;Library: Standard C Library (libc.a)<br>
<!-- iddvc RMBR -->
<br>
&nbsp;&nbsp;Threadsafe: Yes<br>
<!-- iddvc RMBR -->
<br>
</div>
<br>
<p><strong>Note:</strong> These functions can only be used in an i5/OS PASE
program. See <a href="../rzalf/rzalfintro.htm">i5/OS PASE</a> for more
information about creating i5/OS PASE programs.</p>
<p>The <strong>fork400()</strong> function creates a new process.
The new process (the child process) is an almost exact copy of the
calling process (the parent process).
<strong>fork400()</strong>
is called once (by the parent process), but returns
twice (once in the parent process and once in the child process).
<strong>fork400()</strong> is the same as
the <strong>fork()</strong> function plus it allows additional i5/OS
PASE unique options to be specified.
</p>
<p><strong>f_fork400()</strong> function is a similarly enhanced
version of the <strong>f_fork()</strong> function.
When <strong>f_fork400()</strong> (or <strong>f_fork()</strong>)
is used, one of the <strong>exec</strong> functions must be
called in the child process immediately after
it is created.
<strong>f_fork400()</strong> does not call the fork handlers so
the application data, mutexes and the locks are all undefined
in the child process.
</p>
<br>
<h3>Parameters</h3>
<dl>
<dt><strong>jobname</strong></dt>
<dd>(Input)
Pointer to a null-terminated string in the i5/OS PASE CCSID that specifies the
i5/OS job name of the new process.
<p>The job name specified must begin with an alphabetic character [A-Z] or the characters [$#@].
The remaining characters must be alphanumeric [A-Z] or [0-9] or [$#@_.].
The string should not be longer than 10 characters (not including the terminating null character).
If the specified jobname is invalid, the jobname parameter value is ignored.
</p>
</dd>
<dt><strong>resourceID</strong></dt>
<dd>(Input)
A positive integer value specifying the resources affinity identifier
for the new process.
<p>
Use the value of 0 to
let the operating system select the resources affinity identifier value automatically.
</p>
</dd>
</dl>
<br>
<h3>Authorities</h3>
<p><strong>fork400()</strong> and <strong>f_fork400()</strong> require no authority.</p>
<br>
<h3>Return Value</h3>
<p>Upon successful completion, the <strong>fork400()</strong>
or <strong>f_fork400()</strong> function returns a value of 0
to the child process and the process ID of the child process
to the parent process. Otherwise, a value of -1 is returned
to the parent process, no child process is created,
and the errno global variable is set to indicate the error.
</p>
<br>
<h3>Error Conditions</h3>
<p>At least these errno values can be returned, with other values also possible
(such as i5/OS-unique ILE errno EAPAR):</p>
<table cellpadding="5">
<!-- cols="25 75" -->
<tr>
<td align="left" valign="top"><em>[EAGAIN]</em></td>
<td align="left" valign="top">Exceeds the limit on the total number of processes
running or the system does not have the resources necessary to create
another process.
</td>
</tr>
<tr>
<td align="left" valign="top"><em>[ENOMEM]</em></td>
<td align="left" valign="top">Not enough space exists for this process.
</td>
</tr>
<tr>
<td align="left" valign="top"><em>[EINVAL]</em></td>
<td align="left" valign="top">An invalid argument value was specified.
</td>
</tr>
</table>
<br>
<br>
<h3>Usage Notes</h3>
<ol>
<li>Consult the AIX documentation for <strong>fork()</strong>
and <strong>f_fork()</strong> for additional details regarding
attributes of the parent process inherited by the
child process and differences between <strong>fork()</strong> and <strong>f_fork()</strong>.
<br>
</li>
<li>The i5/OS PASE environment specification <em>QIBM_PASE_USE_PRESTART_JOBS=Y</em>
will be ignored when the fork400() or f_fork400() functions are used with a non-null jobname
or a non-zero resourceID value.
</li>
</ol>
<br>
<h3>Related Information</h3>
<ul>
<li>See the <a href="pase_environ.htm">i5/OS PASE Environment Variables</a>
documentation for information about the <em>PASE_FORK_JOBNAME</em>
environment variable that can be used to specify the
i5/OS job name for new processes created using
the <strong>fork()</strong> or <strong>f_fork()</strong> functions.
</li>
</ul>
<br>
<p></p>
<hr>
API introduced: V5R3
<hr>
<center>
<table cellpadding="2" cellspacing="2">
<tr align="center">
<td valign="middle" align="center"><a href="#Top_Of_Page">Top</a> | <a href=
"pase1.htm">i5/OS PASE APIs</a> | <a href="aplist.htm">APIs by category</a>
</td>
</tr>
</table>
</center>
</body>
</html>