📄 os-process.html
字号:
a tuple. <var>mode</var> is a magic operational constant. See the Visual
C++ Runtime Library documentation for further information; the
constants are exposed to the Python programmer as listed below.
Availability: Unix, Windows.
New in version 1.5.2.
</dl>
<P>
<dl><dt><b><a name='l2h-997'><tt>P_WAIT</tt></a></b>
<dd>
<dt><b><a name='l2h-1012'><tt>P_NOWAIT</tt></a></b><dd>
<dt><b><a name='l2h-1013'><tt>P_NOWAITO</tt></a></b><dd>
Possible values for the <var>mode</var> parameter to <tt class="function">spawnv()</tt>
and <tt class="function">spawnve()</tt>.
Availability: Unix, Windows.
New in version 1.5.2.
</dl>
<P>
<dl><dt><b><a name='l2h-998'><tt>P_OVERLAY</tt></a></b>
<dd>
<dt><b><a name='l2h-1014'><tt>P_DETACH</tt></a></b><dd>
Possible values for the <var>mode</var> parameter to <tt class="function">spawnv()</tt>
and <tt class="function">spawnve()</tt>. These are less portable than those listed
above.
Availability: Windows.
New in version 1.5.2.
</dl>
<P>
<dl><dt><b><a name='l2h-999'><tt class='function'>startfile</tt></a></b> (<var>path</var>)
<dd>
Start a file with its associated application. This acts like
double-clicking the file in Windows Explorer, or giving the file name
as an argument to the DOS <b class="program">start</b> command: the file is opened
with whatever application (if any) its extension is associated.
<P>
<tt class="function">startfile()</tt> returns as soon as the associated application
is launched. There is no option to wait for the application to close,
and no way to retrieve the application's exit status. The <var>path</var>
parameter is relative to the current directory. If you want to use an
absolute path, make sure the first character is not a slash
("<tt class="character">/</tt>"); the underlying Win32 <tt class="cfunction">ShellExecute()</tt>
function doesn't work it is. Use the <tt class="function">os.path.normpath()</tt>
function to ensure that the path is properly encoded for Win32.
Availability: Windows.
New in version 2.0.
</dl>
<P>
<dl><dt><b><a name='l2h-1000'><tt class='function'>system</tt></a></b> (<var>command</var>)
<dd>
Execute the command (a string) in a subshell. This is implemented by
calling the Standard C function <tt class="cfunction">system()</tt>, and has the
same limitations. Changes to <code>posix.environ</code>, <code>sys.stdin</code>,
etc. are not reflected in the environment of the executed command.
The return value is the exit status of the process encoded in the
format specified for <tt class="function">wait()</tt>, except on Windows 95 and 98,
where it is always <code>0</code>. Note that POSIX does not specify the
meaning of the return value of the C <tt class="cfunction">system()</tt> function,
so the return value of the Python function is system-dependent.
Availability: Unix, Windows.
</dl>
<P>
<dl><dt><b><a name='l2h-1001'><tt class='function'>times</tt></a></b> ()
<dd>
Return a 5-tuple of floating point numbers indicating accumulated (CPU
or other)
times, in seconds. The items are: user time, system time, children's
user time, children's system time, and elapsed real time since a fixed
point in the past, in that order. See the Unix manual page
<span class='manpage'><i>times</i>(2)</span> or the corresponding Windows Platform API
documentation.
Availability: Unix, Windows.
</dl>
<P>
<dl><dt><b><a name='l2h-1002'><tt class='function'>wait</tt></a></b> ()
<dd>
Wait for completion of a child process, and return a tuple containing
its pid and exit status indication: a 16-bit number, whose low byte is
the signal number that killed the process, and whose high byte is the
exit status (if the signal number is zero); the high bit of the low
byte is set if a core file was produced.
Availability: Unix.
</dl>
<P>
<dl><dt><b><a name='l2h-1003'><tt class='function'>waitpid</tt></a></b> (<var>pid, options</var>)
<dd>
Wait for completion of a child process given by process id <var>pid</var>,
and return a tuple containing its process id and exit status
indication (encoded as for <tt class="function">wait()</tt>). The semantics of the
call are affected by the value of the integer <var>options</var>, which
should be <code>0</code> for normal operation.
Availability: Unix.
<P>
If <var>pid</var> is greater than <code>0</code>, <tt class="function">waitpid()</tt> requests
status information for that specific process. If <var>pid</var> is
<code>0</code>, the request is for the status of any child in the process
group of the current process. If <var>pid</var> is <code>-1</code>, the request
pertains to any child of the current process. If <var>pid</var> is less
than <code>-1</code>, status is requested for any process in the process
group <code>-<var>pid</var></code> (the absolute value of <var>pid</var>).
</dl>
<P>
<dl><dt><b><a name='l2h-1004'><tt>WNOHANG</tt></a></b>
<dd>
The option for <tt class="function">waitpid()</tt> to avoid hanging if no child
process status is available immediately.
Availability: Unix.
</dl>
<P>
The following functions take a process status code as returned by
<tt class="function">system()</tt>, <tt class="function">wait()</tt>, or <tt class="function">waitpid()</tt> as a
parameter. They may be used to determine the disposition of a
process.
<P>
<dl><dt><b><a name='l2h-1005'><tt class='function'>WIFSTOPPED</tt></a></b> (<var>status</var>)
<dd>
Return true if the process has been stopped.
Availability: Unix.
</dl>
<P>
<dl><dt><b><a name='l2h-1006'><tt class='function'>WIFSIGNALED</tt></a></b> (<var>status</var>)
<dd>
Return true if the process exited due to a signal.
Availability: Unix.
</dl>
<P>
<dl><dt><b><a name='l2h-1007'><tt class='function'>WIFEXITED</tt></a></b> (<var>status</var>)
<dd>
Return true if the process exited using the <span class='manpage'><i>exit</i>(2)</span> system
call.
Availability: Unix.
</dl>
<P>
<dl><dt><b><a name='l2h-1008'><tt class='function'>WEXITSTATUS</tt></a></b> (<var>status</var>)
<dd>
If <code>WIFEXITED(<var>status</var>)</code> is true, return the integer
parameter to the <span class='manpage'><i>exit</i>(2)</span> system call. Otherwise, the return
value is meaningless.
Availability: Unix.
</dl>
<P>
<dl><dt><b><a name='l2h-1009'><tt class='function'>WSTOPSIG</tt></a></b> (<var>status</var>)
<dd>
Return the signal which caused the process to stop.
Availability: Unix.
</dl>
<P>
<dl><dt><b><a name='l2h-1010'><tt class='function'>WTERMSIG</tt></a></b> (<var>status</var>)
<dd>
Return the signal which caused the process to exit.
Availability: Unix.
</dl>
<P>
<DIV CLASS="navigation"><p><hr><table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A href="os-file-dir.html" tppabs="http://www.python.org/doc/current/lib/os-file-dir.html"><img src="previous.gif" tppabs="http://www.python.org/doc/current/icons/previous.gif" border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A href="module-os.html" tppabs="http://www.python.org/doc/current/lib/module-os.html"><img src="up.gif" tppabs="http://www.python.org/doc/current/icons/up.gif" border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A href="os-path.html" tppabs="http://www.python.org/doc/current/lib/os-path.html"><img src="next.gif" tppabs="http://www.python.org/doc/current/icons/next.gif" border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td><A href="contents.html" tppabs="http://www.python.org/doc/current/lib/contents.html"><img src="contents.gif" tppabs="http://www.python.org/doc/current/icons/contents.gif" border="0" height="32"
alt="Contents" width="32"></A></td>
<td><a href="modindex.html" tppabs="http://www.python.org/doc/current/lib/modindex.html" title="Module Index"><img src="modules.gif" tppabs="http://www.python.org/doc/current/icons/modules.gif" border="0" height="32"
alt="Module Index" width="32"></a></td>
<td><A href="genindex.html" tppabs="http://www.python.org/doc/current/lib/genindex.html"><img src="index.gif" tppabs="http://www.python.org/doc/current/icons/index.gif" border="0" height="32"
alt="Index" width="32"></A></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" href="os-file-dir.html" tppabs="http://www.python.org/doc/current/lib/os-file-dir.html">6.1.4 Files and Directories</A>
<b class="navlabel">Up:</b> <a class="sectref" href="module-os.html" tppabs="http://www.python.org/doc/current/lib/module-os.html">6.1 os </A>
<b class="navlabel">Next:</b> <a class="sectref" href="os-path.html" tppabs="http://www.python.org/doc/current/lib/os-path.html">6.1.6 Miscellaneous System Information</A>
</DIV>
<!--End of Navigation Panel-->
<ADDRESS>
<hr>See <i><a href="about.html" tppabs="http://www.python.org/doc/current/lib/about.html">About this document...</a></i> for information on suggesting changes.
</ADDRESS>
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -