.\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk) .\" .\" %%%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 .\" .\" References consulted: .\" Linux libc source code .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991) .\" 386BSD man pages .\" Modified 1993-04-02, David Metcalfe .\" Modified 1993-07-25, Rik Faith (faith@cs.unc.edu) .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .\" .\" Japanese Version Copyright (c) 1997 Seiichi Yoshida .\" all rights reserved. .\" Translated 1997-02-14, Seiichi Yoshida .\" Updated 2002-09-27, Kentaro Shirakata .\" Updated 2005-02-26, Akihiro MOTOKI .\" Updated 2008-12-26, Akihiro MOTOKI, LDP v3.15 .\" .TH ON_EXIT 3 2014\-08\-19 GNU "Linux Programmer's Manual" .SH 名前 on_exit \- プロセスが正常に終了した際に呼ばれる関数を登録する .SH 書式 .nf \fB#include \fP .sp \fBint on_exit(void (*\fP\fIfunction\fP\fB)(int , void *), void *\fP\fIarg\fP\fB);\fP .fi .sp .in -4n glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7) 参照): .in .sp \fBon_exit\fP(): _BSD_SOURCE || _SVID_SOURCE .SH 説明 \fBon_exit\fP() 関数は、指定された関数 \fIfunction\fP を、プロセスが 正常に終了した際に呼ばれる関数として登録する。正常な終了とは、 \fBexit\fP(3) またはプログラムの \fImain\fP() 関数の中の return 命令による終了である。 関数 \fIfunction\fP には、直近の \fBexit\fP(3) の呼び出しで渡された status 引数と \fBon_exit\fP() の \fIarg\fP 引数が渡される。 同じ関数を複数回登録してもよい。 登録された関数は登録 1 回につき 1 回呼び出される。 \fBfork\fP(2) で作成された場合、子プロセスは親プロセスの登録のコピーを継承する。 \fBexec\fP(3) ファミリーの関数の場合、呼び出しに成功すると、 全ての登録が削除される。 .SH 返り値 \fBon_exit\fP() 関数は、成功したら 0 を、そうでなければ 0 以外を返す。 .SH 準拠 この関数は SunOS 4 由来であるが、 glibc にも存在する。 Solaris (SunOS 5) にはもはや存在しない。移植性が必要なアプリケーションではこの関数の使用は避け、代わりに標準の \fBatexit\fP(3) を使うこと。 .SH 関連項目 \fB_exit\fP(2), \fBatexit\fP(3), \fBexit\fP(3) .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.79 の一部 である。プロジェクトの説明とバグ報告に関する情報は http://www.kernel.org/doc/man\-pages/ に書かれている。