[Learning Notes] 5 ways to terminate a process

Source: Internet
Author: User

5 ways to terminate a process

Q Normal Exit

Q returns from the main function

Q Call Exit

Q Call _exit

Q Abnormal exit

Q Call abort to generate Sigabout signal

Q Stop by signal CTRL + C SIGINT

eg

Difference 1: Emptying the buffer operation

int main (void)

{

printf ("Hello Itcast");

return 0;

Exit (0);

Fflush (stdout);

_exit (0);

}

Difference 2:exit Call Termination handler

About terminating handlers

Q atexit can register a termination handler, and ANSI c specifies that up to 32 termination handlers can be registered.

Q Termination Handler's call is reversed from the registration order

Q Mans atexit

int atexit (void (*function) (void));

Mans 2 Atexit

Summarize exit and _exit differences

1) _exit is a system call, Exit is a C library function

2) Exit performs a clear I/O cache

3) exit executes the call termination handler

Copy to Google TranslateTranslation Results

[Learning Notes] 5 ways to terminate a process

Related Article

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.