C-standard-library-c-function-exit

提供:Dev Guides
移動先:案内検索

Cライブラリ関数-exit()

説明

Cライブラリ関数* void exit(int status)*は、呼び出しプロセスをすぐに終了します。 プロセスに属する開いているファイル記述子はすべて閉じられ、プロセスの子はプロセス1、initによって継承され、プロセスの親にはSIGCHLDシグナルが送信されます。

宣言

以下は、exit()関数の宣言です。

void exit(int status)

パラメーター

  • ステータス-これは親プロセスに返されるステータス値です。

戻り値

この関数は値を返しません。

次の例は、exit()関数の使用法を示しています。

#include <stdio.h>
#include <stdlib.h>

int main () {
   printf("Start of the program....\n");

   printf("Exiting the program....\n");
   exit(0);

   printf("End of the program....\n");

   return(0);
}

次の結果を生成する上記のプログラムをコンパイルして実行しましょう-

Start of the program....
Exiting the program....