25 December 2017

Process Management in Python - os._exit()

This is a continuation of series of posts on Process management in Python. Read thisthis and this before continuing further. In this post, we are going to see how os._exit works and how it is related to "wait".

os._exit when invoked, the process that is calling it terminates immediately without doing any clean-ups (however system.exit() can be handled by the Python program, a much safer/clean way). The parent process receives the exit status when the parent process calls "wait" or "waitpid. os._exit calls _exit of OS

The following code demonstrates it. Beware, os._exit exits the process abruptly.

For more information on exit and _exit refer - https://en.wikipedia.org/wiki/Exit_(system_call)

Refer the Code in GIT Hub

Here is the code in Python (being Python, it is self-explanatory :-))

No comments: