Abort function of Signal

Source: Internet
Author: User

The function of the abort function is to terminate an abnormal program.

#include <stdlib.h> abort(

This function sends the SIGABRT signal to the calling Process(The process should not ignore this signal ). According to iso c, calling abort will deliver an unsuccessful Termination notification to the host environment by calling the raise (SIGABRT) function.

Instance

Program list 10-18 Implementation of POSIX.1 in abort

#include <signal.h><stdio.h><stdlib.h><unistd.h>)    &(action.sa_handler ===&(action.sa_handler ==    &&mask, SIGABRT);    &    =&action, NULL);    &mask, NULL)    );    

First, check whether the default action is performed. If so, the standard I/O Stream is flushed. This is not equivalent to calling fclose for all opened streams (because only fl is used, and they are not closed), but when the process is terminated, the system will close all opened files. If the process captures this signal and returns it, the process may generate more output, so it rewrites all the streams. The only condition for not flushing is if the process captures this signal and then calls _ exit or _ Exit. In this case, any unwashed standard I/O buffer in the memory is discarded.

If kill is called to generate a signal for the caller and the signal is not blocked (this is ensured in the program list 10-18), before kill returns, the signal (or a pending, unblocked signal) is sent to the process (http://www.cnblogs.com/nufangrensheng/p/3514817.html ). We block all signals other than SIGABRT, so we can see that if the call to kill is returned, the improvement must have captured the signal and also returned from the signal processing program.

 

 

 

 

 

 

 

 

 

This blog is excerpted from advanced programming for UNIX environments (version 2) and used only for personal learning records. For more information about this book, see:Http://www.apuebook.com/.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.