Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / amd64 / html / python / lib / os-procinfo.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link rel="STYLESHEET" href="lib.css" type='text/css' />
<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
<link rel='start' href='../index.html' title='Python Documentation Index' />
<link rel="first" href="lib.html" title='Python Library Reference' />
<link rel='contents' href='contents.html' title="Contents" />
<link rel='index' href='genindex.html' title='Index' />
<link rel='last' href='about.html' title='About this document...' />
<link rel='help' href='about.html' title='About this document...' />
<link rel="next" href="os-newstreams.html" />
<link rel="prev" href="module-os.html" />
<link rel="parent" href="module-os.html" />
<link rel="next" href="os-newstreams.html" />
<meta name='aesop' content='information' />
<title>6.1.1 Process Parameters </title>
</head>
<body>
<DIV CLASS="navigation">
<div id='top-navigation-panel' xml:id='top-navigation-panel'>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="6.1 os "
href="module-os.html"><img src='../icons/previous.png'
border='0' height='32' alt='Previous Page' width='32' /></A></td>
<td class='online-navigation'><a rel="parent" title="6.1 os "
href="module-os.html"><img src='../icons/up.png'
border='0' height='32' alt='Up One Level' width='32' /></A></td>
<td class='online-navigation'><a rel="next" title="6.1.2 File Object Creation"
href="os-newstreams.html"><img src='../icons/next.png'
border='0' height='32' alt='Next Page' width='32' /></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
href="contents.html"><img src='../icons/contents.png'
border='0' height='32' alt='Contents' width='32' /></A></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
border='0' height='32' alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
href="genindex.html"><img src='../icons/index.png'
border='0' height='32' alt='Index' width='32' /></A></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="module-os.html">6.1 os </A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="module-os.html">6.1 os </A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="os-newstreams.html">6.1.2 File Object Creation</A>
</div>
<hr /></div>
</DIV>
<!--End of Navigation Panel-->
<H2><A NAME="SECTION008110000000000000000"></A><A NAME="os-procinfo"></A>
<BR>
6.1.1 Process Parameters
</H2>
<P>
These functions and data items provide information and operate on the
current process and user.
<P>
<dl><dt><b><tt id='l2h-1508' xml:id='l2h-1508'>environ</tt></b></dt>
<dd>
A mapping object representing the string environment. For example,
<code>environ['HOME']</code> is the pathname of your home directory (on some
platforms), and is equivalent to <code>getenv("HOME")</code> in C.
<P>
This mapping is captured the first time the <tt class="module">os</tt> module is
imported, typically during Python startup as part of processing
<span class="file">site.py</span>. Changes to the environment made after this time are
not reflected in <code>os.environ</code>, except for changes made by modifying
<code>os.environ</code> directly.
<P>
If the platform supports the <tt class="function">putenv()</tt> function, this
mapping may be used to modify the environment as well as query the
environment. <tt class="function">putenv()</tt> will be called automatically when
the mapping is modified.
<span class="note"><b class="label">Note:</b>
Calling <tt class="function">putenv()</tt> directly does not change
<code>os.environ</code>, so it's better to modify <code>os.environ</code>.</span>
<span class="note"><b class="label">Note:</b>
On some platforms, including FreeBSD and Mac OS X, setting
<code>environ</code> may cause memory leaks. Refer to the system documentation
for <tt class="cfunction">putenv()</tt>.</span>
<P>
If <tt class="function">putenv()</tt> is not provided, a modified copy of this mapping
may be passed to the appropriate process-creation functions to cause
child processes to use a modified environment.
<P>
If the platform supports the <tt class="function">unsetenv()</tt> function, you can
delete items in this mapping to unset environment variables.
<tt class="function">unsetenv()</tt> will be called automatically when an item is
deleted from <code>os.environ</code>.
<P>
</dd></dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt class="function">chdir</tt></b>(</nobr></td>
<td><var>path</var>)</td></tr></table></dt>
<dd>
<dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt class="function">fchdir</tt></b>(</nobr></td>
<td><var>fd</var>)</td></tr></table></dt>
<dd><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt class="function">getcwd</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>These functions are described in ``Files and Directories'' (section
<A href="os-file-dir.html#os-file-dir">6.1.4</A>).
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1509' xml:id='l2h-1509' class="function">ctermid</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
Return the filename corresponding to the controlling terminal of the
process.
Availability: <span class="Unix">Unix</span>.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1510' xml:id='l2h-1510' class="function">getegid</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
Return the effective group id of the current process. This
corresponds to the `set id' bit on the file being executed in the
current process.
Availability: <span class="Unix">Unix</span>.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1511' xml:id='l2h-1511' class="function">geteuid</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
<a id='l2h-1541' xml:id='l2h-1541'></a>
Return the current process' effective user id.
Availability: <span class="Unix">Unix</span>.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1512' xml:id='l2h-1512' class="function">getgid</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
<a id='l2h-1542' xml:id='l2h-1542'></a>
Return the real group id of the current process.
Availability: <span class="Unix">Unix</span>.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1513' xml:id='l2h-1513' class="function">getgroups</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
Return list of supplemental group ids associated with the current
process.
Availability: <span class="Unix">Unix</span>.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1514' xml:id='l2h-1514' class="function">getlogin</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
Return the name of the user logged in on the controlling terminal of
the process. For most purposes, it is more useful to use the
environment variable <a class="envvar" id='l2h-1543' xml:id='l2h-1543'>LOGNAME</a> to find out who the user is,
or <code>pwd.getpwuid(os.getuid())[0]</code> to get the login name
of the currently effective user ID.
Availability: <span class="Unix">Unix</span>.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1515' xml:id='l2h-1515' class="function">getpgid</tt></b>(</nobr></td>
<td><var>pid</var>)</td></tr></table></dt>
<dd>
Return the process group id of the process with process id <var>pid</var>.
If <var>pid</var> is 0, the process group id of the current process is
returned. Availability: <span class="Unix">Unix</span>.
<span class="versionnote">New in version 2.3.</span>
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1516' xml:id='l2h-1516' class="function">getpgrp</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
<a id='l2h-1544' xml:id='l2h-1544'></a>
Return the id of the current process group.
Availability: <span class="Unix">Unix</span>.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1517' xml:id='l2h-1517' class="function">getpid</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
<a id='l2h-1545' xml:id='l2h-1545'></a>
Return the current process id.
Availability: <span class="Unix">Unix</span>, Windows.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1518' xml:id='l2h-1518' class="function">getppid</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
<a id='l2h-1546' xml:id='l2h-1546'></a>
Return the parent's process id.
Availability: <span class="Unix">Unix</span>.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1519' xml:id='l2h-1519' class="function">getuid</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
<a id='l2h-1547' xml:id='l2h-1547'></a>
Return the current process' user id.
Availability: <span class="Unix">Unix</span>.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1520' xml:id='l2h-1520' class="function">getenv</tt></b>(</nobr></td>
<td><var>varname</var><big>[</big><var>, value</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Return the value of the environment variable <var>varname</var> if it
exists, or <var>value</var> if it doesn't. <var>value</var> defaults to
<code>None</code>.
Availability: most flavors of <span class="Unix">Unix</span>, Windows.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1521' xml:id='l2h-1521' class="function">putenv</tt></b>(</nobr></td>
<td><var>varname, value</var>)</td></tr></table></dt>
<dd>
<a id='l2h-1548' xml:id='l2h-1548'></a>
Set the environment variable named <var>varname</var> to the string
<var>value</var>. Such changes to the environment affect subprocesses
started with <tt class="function">os.system()</tt>, <tt class="function">popen()</tt> or
<tt class="function">fork()</tt> and <tt class="function">execv()</tt>.
Availability: most flavors of <span class="Unix">Unix</span>, Windows.
<P>
<span class="note"><b class="label">Note:</b>
On some platforms, including FreeBSD and Mac OS X,
setting <code>environ</code> may cause memory leaks.
Refer to the system documentation for putenv.</span>
<P>
When <tt class="function">putenv()</tt> is
supported, assignments to items in <code>os.environ</code> are automatically
translated into corresponding calls to <tt class="function">putenv()</tt>; however,
calls to <tt class="function">putenv()</tt> don't update <code>os.environ</code>, so it is
actually preferable to assign to items of <code>os.environ</code>.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1522' xml:id='l2h-1522' class="function">setegid</tt></b>(</nobr></td>
<td><var>egid</var>)</td></tr></table></dt>
<dd>
Set the current process's effective group id.
Availability: <span class="Unix">Unix</span>.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1523' xml:id='l2h-1523' class="function">seteuid</tt></b>(</nobr></td>
<td><var>euid</var>)</td></tr></table></dt>
<dd>
Set the current process's effective user id.
Availability: <span class="Unix">Unix</span>.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1524' xml:id='l2h-1524' class="function">setgid</tt></b>(</nobr></td>
<td><var>gid</var>)</td></tr></table></dt>
<dd>
Set the current process' group id.
Availability: <span class="Unix">Unix</span>.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1525' xml:id='l2h-1525' class="function">setgroups</tt></b>(</nobr></td>
<td><var>groups</var>)</td></tr></table></dt>
<dd>
Set the list of supplemental group ids associated with the current
process to <var>groups</var>. <var>groups</var> must be a sequence, and each
element must be an integer identifying a group. This operation is
typical available only to the superuser.
Availability: <span class="Unix">Unix</span>.
<span class="versionnote">New in version 2.2.</span>
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1526' xml:id='l2h-1526' class="function">setpgrp</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
Calls the system call <tt class="cfunction">setpgrp()</tt> or <tt class="cfunction">setpgrp(0,
0)</tt> depending on which version is implemented (if any). See the
<span class="Unix">Unix</span> manual for the semantics.
Availability: <span class="Unix">Unix</span>.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1527' xml:id='l2h-1527' class="function">setpgid</tt></b>(</nobr></td>
<td><var>pid, pgrp</var>)</td></tr></table></dt>
<dd> Calls the system call
<tt class="cfunction">setpgid()</tt> to set the process group id of the process with
id <var>pid</var> to the process group with id <var>pgrp</var>. See the <span class="Unix">Unix</span>
manual for the semantics.
Availability: <span class="Unix">Unix</span>.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1528' xml:id='l2h-1528' class="function">setreuid</tt></b>(</nobr></td>
<td><var>ruid, euid</var>)</td></tr></table></dt>
<dd>
Set the current process's real and effective user ids.
Availability: <span class="Unix">Unix</span>.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1529' xml:id='l2h-1529' class="function">setregid</tt></b>(</nobr></td>
<td><var>rgid, egid</var>)</td></tr></table></dt>
<dd>
Set the current process's real and effective group ids.
Availability: <span class="Unix">Unix</span>.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1530' xml:id='l2h-1530' class="function">getsid</tt></b>(</nobr></td>
<td><var>pid</var>)</td></tr></table></dt>
<dd>
Calls the system call <tt class="cfunction">getsid()</tt>. See the <span class="Unix">Unix</span> manual
for the semantics.
Availability: <span class="Unix">Unix</span>.
<span class="versionnote">New in version 2.4.</span>
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1531' xml:id='l2h-1531' class="function">setsid</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
Calls the system call <tt class="cfunction">setsid()</tt>. See the <span class="Unix">Unix</span> manual
for the semantics.
Availability: <span class="Unix">Unix</span>.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1532' xml:id='l2h-1532' class="function">setuid</tt></b>(</nobr></td>
<td><var>uid</var>)</td></tr></table></dt>
<dd>
<a id='l2h-1549' xml:id='l2h-1549'></a>
Set the current process' user id.
Availability: <span class="Unix">Unix</span>.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1533' xml:id='l2h-1533' class="function">strerror</tt></b>(</nobr></td>
<td><var>code</var>)</td></tr></table></dt>
<dd>
Return the error message corresponding to the error code in
<var>code</var>.
Availability: <span class="Unix">Unix</span>, Windows.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1534' xml:id='l2h-1534' class="function">umask</tt></b>(</nobr></td>
<td><var>mask</var>)</td></tr></table></dt>
<dd>
Set the current numeric umask and returns the previous umask.
Availability: <span class="Unix">Unix</span>, Windows.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1535' xml:id='l2h-1535' class="function">uname</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
Return a 5-tuple containing information identifying the current
operating system. The tuple contains 5 strings:
<code>(<var>sysname</var>, <var>nodename</var>, <var>release</var>, <var>version</var>,
<var>machine</var>)</code>. Some systems truncate the nodename to 8
characters or to the leading component; a better way to get the
hostname is <tt class="function">socket.gethostname()</tt>
<a id='l2h-1537' xml:id='l2h-1537'></a>or even
<a id='l2h-1539' xml:id='l2h-1539'></a><code>socket.gethostbyaddr(socket.gethostname())</code>.
Availability: recent flavors of <span class="Unix">Unix</span>.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1540' xml:id='l2h-1540' class="function">unsetenv</tt></b>(</nobr></td>
<td><var>varname</var>)</td></tr></table></dt>
<dd>
<a id='l2h-1550' xml:id='l2h-1550'></a>
Unset (delete) the environment variable named <var>varname</var>. Such
changes to the environment affect subprocesses started with
<tt class="function">os.system()</tt>, <tt class="function">popen()</tt> or <tt class="function">fork()</tt> and
<tt class="function">execv()</tt>. Availability: most flavors of <span class="Unix">Unix</span>, Windows.
<P>
When <tt class="function">unsetenv()</tt> is
supported, deletion of items in <code>os.environ</code> is automatically
translated into a corresponding call to <tt class="function">unsetenv()</tt>; however,
calls to <tt class="function">unsetenv()</tt> don't update <code>os.environ</code>, so it is
actually preferable to delete items of <code>os.environ</code>.
</dl>
<P>
<DIV CLASS="navigation">
<div class='online-navigation'>
<p></p><hr />
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="6.1 os "
href="module-os.html"><img src='../icons/previous.png'
border='0' height='32' alt='Previous Page' width='32' /></A></td>
<td class='online-navigation'><a rel="parent" title="6.1 os "
href="module-os.html"><img src='../icons/up.png'
border='0' height='32' alt='Up One Level' width='32' /></A></td>
<td class='online-navigation'><a rel="next" title="6.1.2 File Object Creation"
href="os-newstreams.html"><img src='../icons/next.png'
border='0' height='32' alt='Next Page' width='32' /></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
href="contents.html"><img src='../icons/contents.png'
border='0' height='32' alt='Contents' width='32' /></A></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
border='0' height='32' alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
href="genindex.html"><img src='../icons/index.png'
border='0' height='32' alt='Index' width='32' /></A></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="module-os.html">6.1 os </A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="module-os.html">6.1 os </A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="os-newstreams.html">6.1.2 File Object Creation</A>
</div>
</div>
<hr />
<span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span>
</DIV>
<!--End of Navigation Panel-->
<ADDRESS>
See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
</ADDRESS>
</BODY>
</HTML>