all Python 3osfunction
os.abort
os — abnormal termination
Terminate the process immediately with SIGABRT (no cleanup).
Syntax
os.abort()
It ends the process with SIGABRT: Python handlers, finally blocks, atexit and buffer flushing do not run, and on Unix a core dump may be left behind. A SIGABRT handler set via signal.signal is not called. On Windows the exit code is 3. It is for crash-with-diagnostics exits, not ordinary termination.
Examples
import os
pid = os.fork() # → ? только Unix: 0 в дочернем процессе, pid ребёнка в родительском
if pid == 0: os.abort() # → ? дочерний процесс мгновенно убит сигналом SIGABRT: finally и atexit не выполняются
print(os.waitstatus_to_exitcode(os.waitpid(pid, 0)[1])) # → ? только Unix: -6, процесс завершён сигналом SIGABRT
print(os.abort(0)) # → TypeError
See also
Open in the full glossarydocs.python.orgReport an inaccuracy