1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date. The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein. The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" References consulted:
24 .\" Linux libc source code
25 .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
27 .\" Modified 1993-03-29, David Metcalfe
28 .\" Modified 1993-07-24, Rik Faith (faith@cs.unc.edu)
29 .\" Modified 2003-10-25, Walter Harms
31 .\" Japanese Version Copyright (c) 1996 Kentaro OGAWA
32 .\" all rights reserved.
33 .\" Translated 2006-07-14, Kentaro OGAWA <k_ogawa@oyna.cc.muroran-it.ac.jp>
34 .\" Updated & Modified 2004-05-23, Yuichi SATO <ysato444@yahoo.co.jp>
35 .\" Updated 2008-12-26, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v3.15
37 .TH ATEXIT 3 2008-12-05 "Linux" "Linux Programmer's Manual"
39 atexit \- ¥×¥í¥»¥¹¤¬Àµ¾ï½ªÎ»¤·¤¿»þ¤Ë¸Æ¤Ó½Ð¤µ¤ì¤ë´Ø¿ô¤òÅÐÏ¿¤¹¤ë
42 .B #include <stdlib.h>
44 .BI "int atexit(void (*" function )(void));
48 ´Ø¿ô¤Ï¡¢Í¿¤¨¤é¤ì¤¿ \fIfunction\fP ¤ò¡¢
50 ¤ä¥×¥í¥°¥é¥à¤Î \fImain\fP()
51 ´Ø¿ô¤«¤é¤ÎÊÖ¤ê¤òÄ̤¸¤Æ¡¢¥×¥í¥»¥¹¤¬Àµ¾ï½ªÎ»¤·¤¿»þ¤Ë¸Æ¤Ó½Ð¤µ¤ì¤ë
53 ¤³¤³¤ÇÄêµÁ¤µ¤ì¤¿´Ø¿ô¤Ï¡¢ÅÐÏ¿¤·¤¿½çÈ֤ȤϵդνçÈ֤ǸƤӽФµ¤ì¤ë¡£
54 ÅÐÏ¿¤·¤¿´Ø¿ô¤Ë°ú¤¿ô¤ÏÅϤµ¤ì¤Ê¤¤¡£
56 Ʊ¤¸´Ø¿ô¤òÊ£¿ô²óÅÐÏ¿¤·¤Æ¤â¤è¤¤¡£
57 ÅÐÏ¿¤µ¤ì¤¿´Ø¿ô¤ÏÅÐÏ¿ 1 ²ó¤Ë¤Ä¤ 1 ²ó¸Æ¤Ó½Ð¤µ¤ì¤ë¡£
59 POSIX.1-2001 ¤Ç¤Ï¡¢¤³¤Î¤è¤¦¤Ê´Ø¿ô¤ò¾¯¤Ê¤¯¤È¤â
61 ¸Ä (32¸Ä) ÅÐÏ¿¤Ç¤¤ë¤³¤È¤òÍ׵ᤷ¤Æ¤¤¤ë¡£
62 ¤½¤Î¼ÂÁõ¤Ç¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤ë¼ÂºÝ¤Î¾å¸Â¤Ï
67 ¤ÇºîÀ®¤µ¤ì¤¿¾ì¹ç¡¢»Ò¥×¥í¥»¥¹¤Ï¿Æ¥×¥í¥»¥¹¤ÎÅÐÏ¿¤Î¥³¥Ô¡¼¤ò·Ñ¾µ¤¹¤ë¡£
69 ¥Õ¥¡¥ß¥ê¡¼¤Î´Ø¿ô¤Î¤¤¤º¤ì¤«¤Î¸Æ¤Ó½Ð¤·¤ËÀ®¸ù¤¹¤ë¤È¡¢
70 Á´¤Æ¤ÎÅÐÏ¿¤¬ºï½ü¤µ¤ì¤ë¡£
73 ´Ø¿ô¤Ï¡¢´Ø¿ôÅÐÏ¿¤¬À®¸ù¤·¤¿»þ¤Ë¤Ï 0 ¤òÊÖ¤¹¡£
74 ¤½¤Î¾¤Î¾ì¹ç¤Ë¤Ï 0 °Ê³°¤ÎÃͤòÊÖ¤¹¡£
76 SVr4, 4.3BSD, C89, C99, POSIX.1-2001.
81 ¤ò»È¤Ã¤ÆÅÐÏ¿¤µ¤ì¤¿´Ø¿ô¤Ï¡¢
82 ¥·¥°¥Ê¥ë¤ÎÇÛÁ÷¤Ë¤è¤ê¥×¥í¥»¥¹¤¬°Û¾ï½ªÎ»¤·¤¿¾ì¹ç¤Ë¤Ï¸Æ¤Ó½Ð¤µ¤ì¤Ê¤¤¡£
84 ÅÐÏ¿¤µ¤ì¤¿´Ø¿ô¤Î°ì¤Ä¤¬
86 ¤ò¸Æ¤Ó½Ð¤·¤¿¾ì¹ç¡¢»Ä¤ê¤Î´Ø¿ô¤Ï¤É¤ì¤âµ¯Æ°¤µ¤ì¤º¡¢
88 ¤Ë¤è¤ê¼Â¹Ô¤µ¤ì¤ë¾¤Î¥×¥í¥»¥¹½ªÎ»¥¹¥Æ¥Ã¥×¤Ï¼Â¹Ô¤µ¤ì¤Ê¤¤¡£
92 ¤ò»È¤Ã¤ÆÅÐÏ¿¤µ¤ì¤¿°ì¤Ä¤Î´Ø¿ôÆâ¤Ç¡¢Ê£¿ô²ó
94 ¤ò¸Æ¤Ó½Ð¤·¤¿ºÝ¤Î·ë²Ì¤Ï̤ÄêµÁ¤Ç¤¢¤ë¡£
95 .\" This can happen on OpenBSD 4.2 for example, and is documented
96 .\" as occurring on FreeBSD as well.
97 .\" Glibc does "the Right Thing" -- invocation of the remaining
98 .\" exit handlers carries on as normal.
99 (Linux ¤Ç¤Ï¤Ê¤¤¤¬) ¤¤¤¯¤Ä¤«¤Î¥·¥¹¥Æ¥à¤Ç¤Ï¡¢¤³¤Î¾ì¹ç¡¢
100 ·«¤êÊÖ¤·¤¬Ìµ¸Â¤Ëµ¯¤³¤ë¤³¤È¤Ë¤Ê¤ë¡£
101 °Ü¿¢À¤¬É¬Í×¤Ê¥×¥í¥°¥é¥à¤Ç¤Ï¡¢
105 ¤òµ¯Æ°¤¹¤Ù¤¤Ç¤Ï¤Ê¤¤¡£
110 ¤Ï¡¢Æ±¤¸¥ê¥¹¥È¤ËÂФ·¤Æ´Ø¿ô¤òÅÐÏ¿¤¹¤ë¡£
111 ¥×¥í¥»¥¹¤¬Àµ¾ï¤Ë½ªÎ»¤·¤¿ºÝ¤Ë¤Ï¡¢
112 ¤³¤ì¤é¤ÎÆó¤Ä¤Î´Ø¿ô¤ÇÅÐÏ¿¤µ¤ì¤¿½ç½ø¤ÎµÕ½ç¤Ç¡¢
113 ÅÐÏ¿¤µ¤ì¤¿´Ø¿ô¤¬µ¯Æ°¤µ¤ì¤ë¡£
117 ¤ÇÅÐÏ¿¤µ¤ì¤¿´Ø¿ô¤Î¼Â¹Ô¤ò½ªÎ»¤¹¤ë¤¿¤á¤Ë
119 ¤¬»ÈÍѤµ¤ì¤¿¾ì¹ç¤Î·ë²Ì¤Ï̤ÄêµÁ¤Ç¤¢¤ë¡£
120 .\" In glibc, things seem to be handled okay
122 glibc 2.2.3 °Ê¹ß¤Ç¤Ï¡¢¶¦Í¥é¥¤¥Ö¥é¥ê¤¬¥¢¥ó¥í¡¼¥É¤µ¤ì¤ë¤È¤¤Ë¸Æ¤Ð¤ì¤ë
123 ´Ø¿ô¤òÅÐÏ¿¤¹¤ë¤¿¤á¤Ë¡¢¶¦Í¥é¥¤¥Ö¥é¥ê¤ÎÃæ¤Ç
127 ¤ò»ÈÍѤ¹¤ë¤³¤È¤¬¤Ç¤¤ë¡£
138 printf("That was all, folks\en");
147 a = sysconf(_SC_ATEXIT_MAX);
148 printf("ATEXIT_MAX = %ld\en", a);
152 fprintf(stderr, "cannot set exit function\en");