_cexit
process.h:インデックス への移動
ヘッダーファイル
process.h
カテゴリ
プロセス制御ルーチン
プロトタイプ
void _cexit(void);
説明
プログラムを終了せずに,exit によるクリーンアップを実行します。
_cexit は exit と同じクリーンアップを実行し,すべてのファイルを閉じますが,呼び出し側のプロセスは終了しません。_cexit 関数は,登録されている「終了関数」(atexit で登録)をすべて呼び出します。_cexit は,すべての入出力バッファをフラッシュし,開いているすべてのストリームを閉じてから戻ります。
戻り値
なし。
例
#include <windows.h>
#include <process.h>
#include <io.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
void exit_func(void)
{
printf("Exit function called\n\n");
printf("Close Window to return to program... It will beep if able to read from file");
}
int main(void)
{
int fd;
char c;
if ((fd = open("_cexit.c",O_RDONLY)) < 0)
{
printf("Unable to open _cexit.c for reading\n");
return 1;
}
atexit(exit_func);
if (read(fd,&c,1) != 1)
printf("Unable to read from open file handle %d before _cexit\n",fd);
else
printf("Successfully read from open file handle %d before _cexit\n",fd);
_cexit();
if (read(fd,&c,1) == 1)
MessageBeep(0);
return 0;
}
移植性
POSIX | Win32 | ANSI C | ANSI C++ |
---|---|---|---|
+ |