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

354 lines
10 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>Qp0wChkChld()--Check Status for Child Processes</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 -->
<!-- This file has undergone error condition cleanup by JET -->
<!-- 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>Qp0wChkChld()--Check Status for Child Processes</h2>
<div class="box" style="width: 70%;">
<br>
&nbsp;&nbsp;Syntax<br>
<pre>
#include &lt;qp0wpid.h&gt;
int Qp0wChkChld(QP0W_PID_Entries_T *<em>chldinfo</em>);
</pre>
<br>
&nbsp;&nbsp;Service Program Name: QP0WPID<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>Qp0wChkChld()</strong> function returns the status and process
table entry information for the child processes of the specified process
ID.</p>
<br>
<h3>Parameters</h3>
<dl>
<dt><strong><em>*chldinfo</em></strong></dt>
<dd>(I/O) A pointer to the <samp>QP0W_PID_Entry_T</samp> structure. This
structure contains the process table entry information for the children
processes identified by <em>pid</em>.</dd>
</dl>
<p>The structure <samp>QP0W_PID_Entry_T</samp> is defined in the <strong>
&lt;qp0wpid.h&gt;</strong> header file as follows:</p>
<pre>
typedef struct QP0W_PID_Entries_T {
int entries_prov;
int entries_could;
int entries_return;
pid_t pid;
QP0W_PID_Data_T entry[1];
} QP0W_PID_Entries_T;
</pre>
<p>The members of the <samp>QP0W_PID_Entry_T</samp> structure are as
follows:</p>
<table cellpadding="5">
<!-- cols="25 75" -->
<tr>
<td align="left" valign="top"><em>int entries_prov;</em></td>
<td align="left" valign="top">(Input) The number of entries of type <samp>
QP0W_PID_Data_T</samp> for which that the caller has allocated storage to
contain the status and process table entry information.<br>
</td>
</tr>
<tr>
<td align="left" valign="top" nowrap><em>int entries_could;</em></td>
<td align="left" valign="top">(Output) The number of entries of type <samp>
QP0W_PID_Data_T</samp> that could be returned. If the <samp>
entries_could</samp> value exceeds the <samp>entries_prov</samp> value, the
<strong>Qp0wChkChld()</strong> function should be called again with sufficient
storage to contain the number of entries returned in <samp>entries_could</samp>
(<samp>entries_prov</samp> must be greater than or equal to <samp>
entries_could</samp>).</td>
</tr>
<tr>
<td align="left" valign="top"><em>int entries_return;</em></td>
<td align="left" valign="top">(Output) The number of entries of type <samp>
QP0W_PID_Data_T</samp> that were returned. If the <samp>entries_return</samp>
value is less than the <samp>entries_prov</samp> value, the content of the
excess number of entries provided is unchanged by <strong>
Qp0wChkChld()</strong>.</td>
</tr>
<tr>
<td align="left" valign="top"><em>pid_t pid;</em></td>
<td align="left" valign="top">(Input) The process ID of the process for which
information about its child processes is to be returned.<br>
</td>
</tr>
<tr>
<td align="left" valign="top" nowrap><em>QP0W_PID_Data_T entry[1];</em></td>
<td align="left" valign="top">(Output) The process table information for child
processes. There is one <samp>QP0W_PID_Data_T</samp> structure entry for each
child process, limited by the value of <samp>entries_prov</samp>.</td>
</tr>
</table>
<p>The structure <samp>QP0W_PID_Data_T</samp> is defined in the <strong>
&lt;qp0wpid.h&gt;</strong> header file as follows:</p>
<pre>
typedef struct QP0W_PID_Data_T {
pid_t pid;
pid_t ppid;
pid_t pgrp;
int status;
unsigned int exit_status;
} QP0W_PID_Data_T;
</pre>
<p>The members of the <samp>QP0W_PID_Data_T</samp> structure are as
follows:</p>
<table cellpadding="5">
<!-- cols="10 90" -->
<tr>
<td align="left" valign="top"><em>pid_t pid;</em></td>
<td align="left" valign="top">The process ID of the process.</td>
</tr>
<tr>
<td align="left" valign="top"><em>pid_t ppid;</em></td>
<td align="left" valign="top">The process ID of the parent process. If <samp>
ppid</samp> has a value of binary 1, there is no parent process associated with
the process.</td>
</tr>
<tr>
<td align="left" valign="top"><em>pid_t pgrp;</em></td>
<td align="left" valign="top">The process group ID of the process.</td>
</tr>
<tr>
<td align="left" valign="top"><em>int status;</em></td>
<td align="left" valign="top">A collection of flag bits that describe the
current state of the process. The following flag bits can be set in <samp>
status</samp>:<br>
<table cellpadding="5">
<tr>
<td align="left" valign="top"><em>QP0W_PID_TERMINATED</em></td>
<td align="left" valign="top">The process has ended.</td>
</tr>
<tr>
<td align="left" valign="top"><em>QP0W_PID_StopPED</em></td>
<td align="left" valign="top">The process has been stopped by a signal.</td>
</tr>
<tr>
<td align="left" valign="top"><em>QP0W_PID_CHILDWAIT</em></td>
<td align="left" valign="top">The process is waiting for a child process to be
ended or stopped by a signal.</td>
</tr>
<tr>
<td align="left" valign="top"><em>QP0W_PID_SIGNALStop</em></td>
<td align="left" valign="top">The process has requested that the SIGCHLD signal
be generated for the process when one of its child processes has been stopped
by a signal.</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="left" valign="top"><em>unsigned int exit_status;</em></td>
<td align="left" valign="top">Exit status of the process. This member only has
meaning if the <samp>status</samp> has been set to <samp>
QP0W_PID_TERMINATED</samp>. Refer to the <strong>wait()</strong> function for a
description of the exit status for a process.</td>
</tr>
</table>
<br>
<br>
<h3>Authorities</h3>
<p>The process calling <strong>Qp0wChkChld()</strong> must have the appropriate
authority to the process being examined. A process is allowed to examine the
process table information for a process if at least one of the following
conditions is true:</p>
<ul>
<li>The process is calling <strong>Qp0wChkChld()</strong> for its own
process.<br>
<br>
</li>
<li>The process has *JOBCTL special authority defined in the process user
profile or in a current adopted user profile.<br>
<br>
</li>
<li>The process is the parent of the process (the process being examined has a
parent process ID equal to the process ID of the process calling <strong>
Qp0wChkChld()</strong>).<br>
<br>
</li>
<li>The real or effective user ID of the process matches the real or effective
user ID of the process calling <strong>Qp0wChkChld()</strong>.</li>
</ul>
<br>
<h3>Return Value</h3>
<table cellpadding="5">
<!-- cols="10 90" -->
<tr>
<td align="left" valign="top"><em>0</em></td>
<td align="left" valign="top"><strong>Qp0wChkChld()</strong> was
successful.</td>
</tr>
<tr>
<td align="left" valign="top"><em>value</em></td>
<td align="left" valign="top"><strong>Qp0wChkChld()</strong> was not
successful. The value returned indicates one of the following errors. Under
some conditions, <em>value</em> could indicate an error other than those listed
here.<br>
<table cellpadding="5">
<tr>
<td align="left" valign="top"><em>[EINVAL]</em></td>
<td align="left" valign="top">The value specified for the argument is not
correct.
<p>A function was passed incorrect argument values, or an operation was
attempted on an object and the operation specified is not supported for that
type of object.</p>
<p>An argument value is not valid, out of range, or NULL.</p>
</td>
</tr>
<tr>
<td align="left" valign="top"><em>[EPERM]</em></td>
<td align="left" valign="top">Operation not permitted.
<p>You must have appropriate privileges or be the owner of the object or other
resource to do the requested operation.</p>
</td>
</tr>
<tr>
<td align="left" valign="top"><em>[ESRCH]</em></td>
<td align="left" valign="top">No item could be found that matches the specified
value.</td>
</tr>
</table>
</td>
</tr>
</table>
<br>
<br>
<h3>Usage Notes</h3>
<p>The <strong>Qp0wChkChld()</strong> function provides an i5/OS-specific way
to obtain the process table information for the child processes of the
specified process.</p>
<br>
<h3>Related Information</h3>
<ul>
<li>The &lt;<strong>qp0wpid.h</strong>&gt; file (see <a href="unix13.htm">
Header Files for UNIX-Type Functions</a>)<br>
<br>
</li>
<li>The &lt;<strong>signal.h</strong>&gt; file (see <a href="unix13.htm">Header
Files for UNIX-Type Functions</a>)<br>
<br>
</li>
<li><a href="getpgrp.htm">getpgrp()</a>--Get Process Group ID<br>
<br>
</li>
<li><a href="getpid.htm">getpid()</a>--Get Process ID<br>
<br>
</li>
<li><a href="getppid.htm">getppid()</a>--Get Process ID of Parent Process<br>
<br>
</li>
<li><a href="qgtpgrp.htm">Qp0wGetPgrp()</a>--Get Process Group ID<br>
<br>
</li>
<li><a href="qgtpid.htm">Qp0wGetPid()</a>--Get Process ID<br>
<br>
</li>
<li><a href="qgtppid.htm">Qp0wGetPPid()</a>--Get Process ID of Parent
Process<br>
<br>
</li>
<li><a href="wait.htm">wait()</a>--Wait for Child Process to End</li>
</ul>
<br>
<hr>
API introduced: V3R6
<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>