.\" -*- coding: UTF-8 -*- .\" Copyright (C) 2001 Andries Brouwer (aeb@cwi.nl) .\" .\" %%%LICENSE_START(VERBATIM) .\" Permission is granted to make and distribute verbatim copies of this .\" manual provided the copyright notice and this permission notice are .\" preserved on all copies. .\" .\" Permission is granted to copy and distribute modified versions of this .\" manual under the conditions for verbatim copying, provided that the .\" entire resulting derived work is distributed under the terms of a .\" permission notice identical to this one. .\" .\" Since the Linux kernel and libraries are constantly changing, this .\" manual page may be incorrect or out-of-date. The author(s) assume no .\" responsibility for errors or omissions, or for damages resulting from .\" the use of the information contained herein. The author(s) may not .\" have taken the same level of care in the production of this manual, .\" which is licensed free of charge, as they might when working .\" professionally. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" %%%LICENSE_END .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .TH GETCONTEXT 3 "21 Diciembre 2020" Linux "Manual del Programador de Linux" .SH NOMBRE getcontext, setcontext \- consulta o establece el contexto de usuario .SH SINOPSIS \fB#include \fP .PP \fBint getcontext(ucontext_t *\fP\fIucp\fP\fB);\fP .br \fBint setcontext(const ucontext_t *\fP\fIucp\fP\fB);\fP .SH DESCRIPCIÓN En un entorno del tipo System V, se encuentran los dos tipos \fImcontext_t\fP y \fIucontext_t\fP definidos en \fI\fP y las cuatro funciones \fBgetcontext\fP(), \fBsetcontext\fP(), \fBmakecontext\fP() y \fBswapcontext\fP() que permiten el intercambio del contexto del nivel de usuario entre múltiples hilos de control dentro de un proceso. .PP El tipo \fImcontext_t\fP es dependiente de la máquina y opaco. El tipo \fIucontext_t\fP es una estructura que tiene al menos los campos siguientes: .PP .in +4n .EX typedef struct ucontext_t { struct ucontext_t *uc_link; sigset_t uc_sigmask; stack_t uc_stack; mcontext_t uc_mcontext; ... } ucontext_t; .EE .in .PP de los cuales \fIsigset_t\fP y \fIstack_t\fP están definidos en \fI\fP. \fIuc_link\fP apunta al contexto que será reanudado cuando termine el contexto actual (en el caso de que el contexto actual haya sido creado usando \fBmakecontext\fP(3)), \fIuc_sigmask\fP es el conjunto de señales bloqueadas en este contexto (véase \fBsigprocmask\fP(2)), \fIuc_stack\fP es la pila usada por este contexto (véase \fBsigaltstack\fP(2)), y \fIuc_mcontext\fP es la representación del contexto guardado específica de la máquina, que incluye los registros de la máquina para el hilo invocador. .PP The function \fBgetcontext\fP() initializes the structure pointed to by \fIucp\fP to the currently active context. .PP The function \fBsetcontext\fP() restores the user context pointed to by \fIucp\fP. A successful call does not return. The context should have been obtained by a call of \fBgetcontext\fP(), or \fBmakecontext\fP(3), or received as the third argument to a signal handler (see the discussion of the \fBSA_SIGINFO\fP flag in \fBsigaction\fP(2)). .PP Si el contexto se obtuvo mediante una llamada a \fBgetcontext\fP(), la ejecución del programa continúa como si esta llamada simplemente regresara. .PP Si el contexto fue obtenido mediante una llamada a \fBmakecontext\fP(3), la ejecución del programa continua por la llamada a la función \fIfunc\fP especificada como segundo argumento en la llamada a \fBmakecontext\fP(3). Cuando la función \fIfunc\fP regresa, se continua con el miembro \fIuc_link\fP de la estructura \fIucp\fP especificada como primer argumento en la llamada a \fBmakecontext\fP(3). Cuando este miembro es NULL, el hilo termina. .PP Cuando el contexto se obtiene mediante una llamada a un manejador de señales, se solía decir que "la ejecución del programa continua con la instrucción de programa siguiente a la instrucción interrumpida por la señal". Sin embargo, esta sentencia fue eliminada en SUSv2, y ahora se establece que "el resultado es indefinido". .SH "VALOR DEVUELTO" Cuando tiene éxito, \fBgetcontext\fP() devuelve 0 y \fBsetcontext\fP() no regresa. En caso de error, ambas devuelven \-1 y modifican \fIerrno\fP con el valor apropiado. .SH ERRORES No se definen errores. .SH ATRIBUTOS Para obtener una explicación de los términos usados en esta sección, véase \fBattributes\fP(7). .TS allbox; lbw26 lb lb l l l. Interfaz Atributo Valor T{ \fBgetcontext\fP(), \fBsetcontext\fP() T} Seguridad del hilo MT\-Safe race:ucp .TE .SH "CONFORME A" SUSv2, POSIX.1\-2001. POSIX.1\-2008 removes the specification of \fBgetcontext\fP(), citing portability issues, and recommending that applications be rewritten to use POSIX threads instead. .SH NOTAS La primera manifestación de este mecanismo fue el mecanismo \fBsetjmp\fP(3)/\fBlongjmp\fP(3). Puesto que no define el manejo del contexto de señales, el siguiente paso fue el par \fBsigsetjmp\fP(3)/\fBsiglongjmp\fP(3). El presente mecanismo proporciona mucho más control. Por otra parte, no hay un método sencillo de detectar si un regreso de \fBgetcontext\fP() es de la primera llamada o via una llamada a \fBsetcontext\fP(). El usuario tiene que inventar su propio mecanismo de `contabilidad' y no se servirá una variable de tipo registro ya que los registros se restauran. .PP Cuando ocurre una señal, el contexto de usuario actual se guarda y el núcleo crea un nuevo contexto para el manejador de señales. No deje al manejador usar \fBlongjmp\fP(3) \- es indefinido que ocurriría con contextos. Use \fBsiglongjmp\fP(3) o \fBsetcontext\fP() en su lugar. .SH "VÉASE TAMBIÉN" \fBsigaction\fP(2), \fBsigaltstack\fP(2), \fBsigprocmask\fP(2), \fBlongjmp\fP(3), \fBmakecontext\fP(3), \fBsigsetjmp\fP(3), \fBsignal\fP(7) .SH COLOFÓN Esta página es parte de la versión 5.10 del proyecto Linux \fIman\-pages\fP. Puede encontrar una descripción del proyecto, información sobre cómo informar errores y la última versión de esta página en \%https://www.kernel.org/doc/man\-pages/. .SH TRADUCCIÓN La traducción al español de esta página del manual fue creada por Miguel Pérez Ibars . Esta traducción es documentación libre; lea la .UR https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3 .UE o posterior con respecto a las condiciones de copyright. No existe NINGUNA RESPONSABILIDAD. Si encuentra algún error en la traducción de esta página del manual, envíe un correo electrónico a .MT debian-l10n-spanish@lists.debian.org>. .ME .