abort

プログラムを異常終了します.

#include <stdlib.h>
void abort(void);

abort 関数は異常プログラム終了を発生させます.(ただし,シグナル SIGABRT が補足されていて,シグナルハンドラ (signal handler) が復帰しない場合を除きます.)

abort 関数を実行したときの以下の動作は処理系定義です.

  • 書き出されていないバッファリング (buffering) されたデータをもつすべてのオープンしているストリーム (stream) をフラッシュするかどうか
  • すべてのオープンしているストリームをクローズするかどうか
  • 一時ファイル (temporary file) を削除するかどうか

C言語サンプルプログラム

abort 関数を使用してプログラムを異常終了するサンプルプログラムを以下に示します.

/* header files */
#include <stdio.h>
#include <stdlib.h>

/* main */
int main(void) {
    printf("異常終了します.\n");
    abort();
    return EXIT_SUCCESS;
}

実行例

サンプルプログラムの実行結果は以下のようになります.

異常終了します.

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.