Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First, no form of program exit will automatically call destructors for heap objects (implied in ISO/IEC 14882:1998(E) 12.4.10).</p> <p>Calling <code>exit()</code> will not call destructors for objects with automatic duration, as it does not return through their enclosing scopes (3.6.1.4). However, destructors for static objects <em>will</em> be called, in reverse order of construction (18.3.8).</p> <p>Calling <code>abort()</code> does not call any destructors for any type of object, nor does it call <code>atexit()</code> registered functions (18.3.3). The C++ standard copy I have here is a bit dated and does not mention <code>_exit</code> or <code>_Exit</code> directly, but I'd imagine that, if present, they should behave the same - that is, not calling any destructors. In particular, in the C99 standard, <code>_Exit()</code> skips <code>atexit</code> handlers (it is implementation defined whether stream buffers are flushed, open streams are closed, or temporary files removed).</p> <p>Further note that <code>abort()</code> can be cancelled by trapping signal <code>SIGABRT</code> (ISO/IEC 9899:1999 (E) 7.20.4.1.2 - I only have C99 here but I expect it would be the same in the version referenced by C++). <code>_Exit()</code> cannot.</p> <p>On a more practical note, on most unix implementations of <code>abort()</code> and <code>_exit()</code>, <code>abort()</code> raises a <code>SIGABRT</code> while <code>_exit()</code> simply calls an operating system call to terminate the process immediately. This means that the main differences are:</p> <ul> <li>You can specify an exit code for <code>_exit()</code></li> <li><code>abort()</code> may be trapped by a signal handler</li> <li>Depending on system configuration, OS, and ulimits, <code>abort()</code> may result in a core dump or similar</li> </ul> <p>In a <code>fork()/exec()</code> pattern, <code>_exit()</code> would probably be preferable, to avoid the possibility of core dump.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload