A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://cplusplus.com/reference/cstdlib/abort/ below:

function

<cstdlib>

abort
[[noreturn]] void abort() noexcept;

Abort current process

Aborts the current process, producing an abnormal program termination.

The function raises the SIGABRT signal (as if raise(SIGABRT) was called). This, if uncaught, causes the program to terminate returning a platform-dependent unsuccessful termination error code to the host environment.

The program is terminated without destroying any object and without calling any of the functions passed to atexit or at_quick_exit.



Parameters none

Return Value none (the function never returns).

Example
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/* abort example */
#include <stdio.h>      /* fopen, fputs, fclose, stderr */
#include <stdlib.h>     /* abort, NULL */

int main ()
{
  FILE * pFile;
  pFile= fopen ("myfile.txt","r");
  if (pFile == NULL)
  {
    fputs ("error opening file\n",stderr);
    abort();
  }

  /* regular process here */

  fclose (pFile);
  return 0;
}

If myfile.txt does not exist, a message is printed and abort is called.

Data races Concurrently calling this function is safe, causing no data races.
Note though that its handling process may affect all threads.

Exceptions (C++) If no function handlers have been defined with signal to handle SIGABRT, the function never throws exceptions (no-throw guarantee).
Otherwise, the behavior depends on the particular library implementation.

See also
exit
Terminate calling process (function)
atexit
Set function to be executed on exit (function)

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4