Python : SIGABRT: Abort signal














































Python : SIGABRT: Abort signal



SIGABRT : Abort Signal

OS module in Python provides functions for interacting with the operating system. OS comes under Python%u2019s standard utility modules. This module provides a portable way of using operating system dependent functionality.

os.abort() method in Python is used to generate a SIGABRT signal to the current process. On Unix, this method produces a core dump while on Windows, the process immediately returns an exit code of 3.
This method does not call the Python signal handler registered for SIGABRT signal with signal.signal() .

This method does not return any value in the calling process.


Example:

Use of os.abort() method

# Python program to explain os.abort() method
import os, signal
# Create a child process
# using os.fork() method
pid = os.fork()

# pid greater than 0
# indicates the parent process
if pid > 0:

print("\nIn Parent process")

# Wait for the completion
# of child process and get
# its pid and exit status indication
# using os.wait() method
info = os.wait()

sig = os.WTERMSIG(info[1])
print("Child exited due to signal no:", sig)
print("Signal name:", signal.Signals(sig).name)
else :
# child process
print("In child process")
print("Process ID:", os.getpid())
print("Hello ! World")

# Abort the child process
# by generating SIGABRT signal
# using os.abort() method
os.abort()
Output :
In child process
Process ID: 13914
Hello! World
 
In Parent process
Child stopped due to signal no: 6
Signal name: SIGABRT



Comments