.\" Copyright (C) 2008, 2014, Michael Kerrisk .\" .\" %%%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 .\" .\" Created Sat Aug 21 1995 Thomas K. Dyas .\" Modified Tue Oct 22 22:09:03 1996 by Eric S. Raymond .\" 2008-06-26, mtk, added some more detail on the work done by sigreturn() .\" 2014-12-05, mtk, rewrote all of the rest of the original page .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .\" .\" Japanese Version Copyright (c) 1997 HANATAKA Shinya .\" all rights reserved. .\" Translated 1997-03-03, HANATAKA Shinya .\" Updated 2005-09-04, Akihiro MOTOKI .\" Updated 2008-08-07, Akihiro MOTOKI, LDP v3.05 .\" .TH SIGRETURN 2 2014\-12\-31 Linux "Linux Programmer's Manual" .SH 名前 sigreturn \- シグナルハンドラーから返り、スタックを掃除する .SH 書式 \fBint sigreturn(...);\fP .SH 説明 .\" See arch/x86/kernel/signal.c::__setup_frame() [in 3.17 source code] Linux カーネルがプロセスに対してブロックされていないシグナルが処理待ちと判定した場合、 そのプロセスの次回のユーザーモードへの遷移 (すなわち、システムコールからのリターン時やそのプロセスが CPU に再スケジュールされる際)、 カーネルはプロセスコンテキストの種々の値 (プロセッサーのステータスワード、 レジスター、 シグナルマスク、 シグナルスタック設定) をユーザー空間のスタックに保存する。 また、 カーネルは、 ユーザーモードへの遷移時にシグナルハンドラーが呼び出され、 ハンドラーからのリターン時に、 制御が "signal trampoline" と呼ばれるユーザー空間コードブロックに渡されるように、準備を行う。 signal trampoline のコードが \fBsigreturn\fP() を呼び出す。 \fBsigreturn\fP() は、シグナルハンドラーを起動するために行ったことの全て \(em プロセスのシグナルマスクの変更、 シグナルスタックの切り替え (\fBsigaltstack\fP(2) 参照) \(em の取り消しを行う。 プロセスのシグナルマスクの復元、 スタックの切り替え、 プロセスのコンテキスト (プロセッサフラグ、 レジスター (スタックポインター、 命令ポインターを含む)) の復元を行い、 プロセスがシグナルにより割り込まれた場所から実行を再開できるようにする。 .SH 返り値 \fBsigreturn\fP() が返ることはない。 .SH 準拠 多くの UNIX 系のシステムには \fBsigreturn\fP() システムコールか似たようなシステムコールがある。 しかしながら、 このシステムコールは POSIX には規定されておらず、 その動作の詳細はシステムにより異なる。 .SH 注意 \fBsigreturn\fP() はシグナルハンドラーを実装するためだけに存在している。 これらを直接呼び出すのは\fB決して\fP行うべきではない。 \fBsigreturn\fP() に渡される引き数の詳細はアーキテクチャーにより異なる。 .\" See, for example, sysdeps/unix/sysv/linux/i386/sigaction.c and .\" sysdeps/unix/sysv/linux/x86_64/sigaction.c in the glibc (2.20) source. かつて、 UNIX システムでは signal trampoline コードがユーザースタックに置かれていた。 今日では、 ユーザースタックのページは保護され、 コードの実行は禁止されている。 したがって、 現代の Linux システムでは、 アーキテクチャー依存ではあるが、 signal trampoline コードは \fBvdso\fP(7) 内もしくは C ライブラリ内に置かれる。 後者の場合、 C ライブラリは trampoline code の場所を \fBsigaction\fP(2) に渡される \fIsigaction\fP 構造体の \fIsa_restorer\fP フィールドを使って渡し、 \fIsa_flags\fP フィールドの \fBSA_RESTORER\fP フラグをセットする。 保存されたプロセスコンテキスト情報は \fIucontext_t\fP構造体に置かれる (\fI\fP 参照)。 この構造体は、 \fBSA_SIGINFO\fP フラグを付けて設定されたシグナルハンドラーの第 3 引き数としてシングルハンドラー内で参照できる。 他のいくつかの UNIX システムでは、 signal trampoline の扱いは少し異なる。 特に、 いくつかのシステムでは、 ユーザーモードに戻る際に、 カーネルは制御を (シグナルハンドラーではなく) trampoline に渡し、 trampoline コードがシグナルハンドラーを呼び出す (その後ハンドラーが返ると \fBsigreturn\fP() を呼び出す)。 .SH 関連項目 \fBkill\fP(2), \fBrestart_syscall\fP(2), \fBsigaltstack\fP(2), \fBsignal\fP(2), \fBgetcontext\fP(3), \fBsignal\fP(7) .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.79 の一部である。 プロジェクトの説明とバグ報告に関する情報は \%http://www.kernel.org/doc/man\-pages/ に書かれている。