.\" Written by Michael Haardt, Fri Nov 25 14:51:42 MET 1994 .\" .\" %%%LICENSE_START(GPLv2+_DOC_FULL) .\" This is free documentation; you can redistribute it and/or .\" modify it under the terms of the GNU General Public License as .\" published by the Free Software Foundation; either version 2 of .\" the License, or (at your option) any later version. .\" .\" The GNU General Public License's references to "object code" .\" and "executables" are to be interpreted as the output of any .\" document formatting or typesetting system, including .\" intermediate and printed output. .\" .\" This manual is distributed in the hope that it will be useful, .\" but WITHOUT ANY WARRANTY; without even the implied warranty of .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the .\" GNU General Public License for more details. .\" .\" You should have received a copy of the GNU General Public .\" License along with this manual; if not, see .\" . .\" %%%LICENSE_END .\" .\" Added sigsetjmp, Sun Mar 2 22:03:05 EST 1997, jrv@vanzandt.mv.com .\" Modifications, Sun Feb 26 14:39:45 1995, faith@cs.unc.edu .\" " .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .\" .\" Japanese Version Copyright (c) 1998 Seiiti Obara .\" all rights reserved. .\" Translated 1998-05-27, Seiiti Obara .\" Updated 1999-12-11, Kentaro Shirakata .\" Modified 2007-12-20, Akihiro MOTOKI .\" Updated 2009-02-12, Kentaro Shirakata .\" .TH SETJMP 3 2014\-01\-07 "" "Linux Programmer's Manual" .SH 名前 setjmp, sigsetjmp \- 非局所的なジャンプのために、スタックコンテキスト (stack context) を保存する .SH 書式 \fB#include \fP .sp .nf \fBint setjmp(jmp_buf \fP\fIenv\fP\fB);\fP \fBint sigsetjmp(sigjmp_buf \fP\fIenv\fP\fB, int \fP\fIsavesigs\fP\fB);\fP .fi .sp .in -4n glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7) 参照): .in .sp \fBsetjmp\fP(): 「注意」参照。 .br \fBsigsetjmp\fP(): _POSIX_C_SOURCE\ >=\ 1 || _XOPEN_SOURCE || _POSIX_C_SOURCE .SH 説明 \fBsetjmp\fP() と \fBlongjmp\fP(3) は、プログラムの低レベルなサブルーチン において、エラーや割り込みが発生した時の処理に便利である。 \fBsetjmp\fP() は、 \fBlongjmp\fP(3) によって使われる \fIenv\fP に スタックコンテキスト/スタック環境を保存する。 \fBsetjmp\fP() を呼び出した 関数が返るときに、そのスタックコンテキストは無効になる。 .P \fBsigsetjmp\fP() も \fBsetjmp\fP() と同様である。 \fIsavesigs\fP が 0 以外の場合、 このプロセスの現在のシグナルマスクも \fIenv\fP に保存され、 このシグナルは後で \fBsiglongjmp\fP(3) がこの \fIenv\fP で実行された際に復元される。 .SH 返り値 直接返ってくるときは、 \fBsetjmp\fP() と \fBsigsetjmp\fP() は 0 を返し、保存したコンテキストを使って \fBlongjmp\fP(3) や \fBsiglongjmp\fP(3) から返ってくるときは 0 以外を返す。 .SH 準拠 \fBsetjmp\fP() は C89, C99, POSIX.1\-2001 で規定されている。 \fBsigsetjmp\fP() は POSIX.1\-2001 で規定されている。 .SH 注意 POSIX は、 (\fBlongjmp\fP() 中で後で復元できるように) \fBsetjmp\fP() がシグナルマスクを保存すべきかどうかを規定していない。 System V では保存しない。 4.3BSD では保存する; 4.3BSD にはシグナルコンテキストを保存しない関数 \fB_setjmp\fP もある。 バージョン 2.19 より前の glibc を使う Linux では、 \fBsetjmp\fP() はデフォルトでは System V の振る舞いに従うが、 \fB_BSD_SOURCE\fP 機能検査マクロが定義され、 \fB_POSIX_SOURCE\fP, \fB_POSIX_C_SOURCE\fP, \fB_XOPEN_SOURCE\fP, \fB_XOPEN_SOURCE_EXTENDED\fP, \fB_GNU_SOURCE\fP, \fB_SVID_SOURCE\fP のいずれも定義されていない時は BSD の振る舞いとなる。 glibc 2.19 以降では、 \fI\fP は System V 版の \fBsetjmp\fP() のみを公開するようになっている。 BSD の動作を必要とするプログラムでは、 \fBsetjmp\fP() の呼び出しを、 \fIsavesigs\fP 引き数に 0 以外の値を渡す \fBsigsetjmp\fP() に置き換えるべきである。 移植性のある形でシグナルマスクを保存および復元したいのなら、 \fBsigsetjmp\fP() と \fBsiglongjmp\fP(3) を使うこと。 .P \fBsetjmp\fP() や \fBsigsetjmp\fP() を使うと、プログラムは理解しづらく、保守しにくいものになる。 別の方法が可能なら、それを使うべきである。 .SH 関連項目 \fBlongjmp\fP(3), \fBsiglongjmp\fP(3) .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.79 の一部 である。プロジェクトの説明とバグ報告に関する情報は http://www.kernel.org/doc/man\-pages/ に書かれている。