Linux Signal (10): abort函数

#include

函数名: abort

 功 能: 异常终止一个进程

 用 法: void abort(void);

 

abort()是使异常程序终止,同时发送SIGABRT信号给调用进程。

 

程序例:

#include 
#include 
void main( void )
{
   FILE *stream;
   if( (stream = fopen( "NOSUCHF.ILE", "r" )) == NULL )
   {
      perror( "Couldn't open file" );
      abort();
   }
   else
      fclose( stream );
}

输出:
Couldn't open file: No such file or directory
abnormal program termination

 

 

你可能感兴趣的:(Linux,APP)