152 lines
6.9 KiB
HTML
152 lines
6.9 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<html>
|
|
<head>
|
|
<meta name="generator" content="HTML Tidy, see www.w3.org">
|
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
|
<link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 -->
|
|
<!-- Copyright (c) 2001 The Open Group, All Rights Reserved -->
|
|
<title>getcontext</title>
|
|
</head>
|
|
<body bgcolor="white">
|
|
<script type="text/javascript" language="JavaScript" src="../jscript/codes.js">
|
|
</script>
|
|
|
|
<basefont size="3"> <a name="getcontext"></a> <a name="tag_03_214"></a><!-- getcontext -->
|
|
<!--header start-->
|
|
<center><font size="2">The Open Group Base Specifications Issue 6<br>
|
|
IEEE Std 1003.1-2001<br>
|
|
Copyright © 2001 The IEEE and The Open Group, All Rights reserved.</font></center>
|
|
|
|
<!--header end-->
|
|
<hr size="2" noshade>
|
|
<h4><a name="tag_03_214_01"></a>NAME</h4>
|
|
|
|
<blockquote>getcontext, setcontext - get and set current user context</blockquote>
|
|
|
|
<h4><a name="tag_03_214_02"></a>SYNOPSIS</h4>
|
|
|
|
<blockquote class="synopsis">
|
|
<div class="box"><code><tt><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt=
|
|
"[Option Start]" border="0"> #include <<a href="../basedefs/ucontext.h.html">ucontext.h</a>><br>
|
|
<br>
|
|
int getcontext(ucontext_t *</tt><i>ucp</i><tt>);<br>
|
|
int setcontext(const ucontext_t *</tt><i>ucp</i><tt>); <img src="../images/opt-end.gif" alt="[Option End]" border="0"></tt></code></div>
|
|
|
|
<tt><br>
|
|
</tt></blockquote>
|
|
|
|
<h4><a name="tag_03_214_03"></a>DESCRIPTION</h4>
|
|
|
|
<blockquote>
|
|
<p>The <i>getcontext</i>() function shall initialize the structure pointed to by <i>ucp</i> to the current user context of the
|
|
calling thread. The <b>ucontext_t</b> type that <i>ucp</i> points to defines the user context and includes the contents of the
|
|
calling thread's machine registers, the signal mask, and the current execution stack.</p>
|
|
|
|
<p>The <i>setcontext</i>() function shall restore the user context pointed to by <i>ucp</i>. A successful call to
|
|
<i>setcontext</i>() shall not return; program execution resumes at the point specified by the <i>ucp</i> argument passed to
|
|
<i>setcontext</i>(). The <i>ucp</i> argument should be created either by a prior call to <i>getcontext</i>() or <a href=
|
|
"../functions/makecontext.html"><i>makecontext</i>()</a>, or by being passed as an argument to a signal handler. If the <i>ucp</i>
|
|
argument was created with <i>getcontext</i>(), program execution continues as if the corresponding call of <i>getcontext</i>() had
|
|
just returned. If the <i>ucp</i> argument was created with <a href="../functions/makecontext.html"><i>makecontext</i>()</a>,
|
|
program execution continues with the function passed to <a href="../functions/makecontext.html"><i>makecontext</i>()</a>. When that
|
|
function returns, the thread shall continue as if after a call to <i>setcontext</i>() with the <i>ucp</i> argument that was input
|
|
to <a href="../functions/makecontext.html"><i>makecontext</i>()</a>. If the <i>uc_link</i> member of the <b>ucontext_t</b>
|
|
structure pointed to by the <i>ucp</i> argument is equal to 0, then this context is the main context, and the thread shall exit
|
|
when this context returns. The effects of passing a <i>ucp</i> argument obtained from any other source are unspecified.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_214_04"></a>RETURN VALUE</h4>
|
|
|
|
<blockquote>
|
|
<p>Upon successful completion, <i>setcontext</i>() shall not return and <i>getcontext</i>() shall return 0; otherwise, a value of
|
|
-1 shall be returned.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_214_05"></a>ERRORS</h4>
|
|
|
|
<blockquote>
|
|
<p>No errors are defined.</p>
|
|
</blockquote>
|
|
|
|
<hr>
|
|
<div class="box"><em>The following sections are informative.</em></div>
|
|
|
|
<h4><a name="tag_03_214_06"></a>EXAMPLES</h4>
|
|
|
|
<blockquote>
|
|
<p>Refer to <a href="makecontext.html"><i>makecontext</i>()</a> .</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_214_07"></a>APPLICATION USAGE</h4>
|
|
|
|
<blockquote>
|
|
<p>When a signal handler is executed, the current user context is saved and a new context is created. If the thread leaves the
|
|
signal handler via <a href="../functions/longjmp.html"><i>longjmp</i>()</a>, then it is unspecified whether the context at the time
|
|
of the corresponding <a href="../functions/setjmp.html"><i>setjmp</i>()</a> call is restored and thus whether future calls to
|
|
<i>getcontext</i>() provide an accurate representation of the current context, since the context restored by <a href=
|
|
"../functions/longjmp.html"><i>longjmp</i>()</a> does not necessarily contain all the information that <i>setcontext</i>()
|
|
requires. Signal handlers should use <a href="../functions/siglongjmp.html"><i>siglongjmp</i>()</a> or <i>setcontext</i>()
|
|
instead.</p>
|
|
|
|
<p>Conforming applications should not modify or access the <i>uc_mcontext</i> member of <b>ucontext_t</b>. A conforming application
|
|
cannot assume that context includes any process-wide static data, possibly including <i>errno</i>. Users manipulating contexts
|
|
should take care to handle these explicitly when required.</p>
|
|
|
|
<p>Use of contexts to create alternate stacks is not defined by this volume of IEEE Std 1003.1-2001.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_214_08"></a>RATIONALE</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_214_09"></a>FUTURE DIRECTIONS</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_214_10"></a>SEE ALSO</h4>
|
|
|
|
<blockquote>
|
|
<p><a href="bsd_signal.html"><i>bsd_signal</i>()</a> , <a href="makecontext.html"><i>makecontext</i>()</a> , <a href=
|
|
"setcontext.html"><i>setcontext</i>()</a> , <a href="setjmp.html"><i>setjmp</i>()</a> , <a href=
|
|
"sigaction.html"><i>sigaction</i>()</a> , <a href="sigaltstack.html"><i>sigaltstack</i>()</a> , <a href=
|
|
"siglongjmp.html"><i>siglongjmp</i>()</a> , <a href="sigprocmask.html"><i>sigprocmask</i>()</a> , <a href=
|
|
"sigsetjmp.html"><i>sigsetjmp</i>()</a> , the Base Definitions volume of IEEE Std 1003.1-2001, <a href=
|
|
"../basedefs/ucontext.h.html"><i><ucontext.h></i></a></p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_214_11"></a>CHANGE HISTORY</h4>
|
|
|
|
<blockquote>
|
|
<p>First released in Issue 4, Version 2.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_214_12"></a>Issue 5</h4>
|
|
|
|
<blockquote>
|
|
<p>Moved from X/OPEN UNIX extension to BASE.</p>
|
|
|
|
<p>The following sentence was removed from the DESCRIPTION: "If the <i>ucp</i> argument was passed to a signal handler, program
|
|
execution continues with the program instruction following the instruction interrupted by the signal."</p>
|
|
</blockquote>
|
|
|
|
<div class="box"><em>End of informative text.</em></div>
|
|
|
|
<hr>
|
|
<hr size="2" noshade>
|
|
<center><font size="2"><!--footer start-->
|
|
UNIX ® is a registered Trademark of The Open Group.<br>
|
|
POSIX ® is a registered Trademark of The IEEE.<br>
|
|
[ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href=
|
|
"../utilities/contents.html">XCU</a> | <a href="../functions/contents.html">XSH</a> | <a href="../xrat/contents.html">XRAT</a>
|
|
]</font></center>
|
|
|
|
<!--footer end-->
|
|
<hr size="2" noshade>
|
|
</body>
|
|
</html>
|
|
|