os._exit(n)
Exit to the system with status n, without calling cleanup handlers, flushing stdio buffers, etc. Availability: Macintosh, Unix, Windows.
Note: The standard way to exit is sys.exit(n). _exit() should normally only be used in the child process after a fork().
sys.exit([arg])
Exit from Python. This is implemented by raising the SystemExit exception, so cleanup actions specified by finally clauses of try statements are honored, and it is possible to intercept the exit attempt at an outer level.
os._exit()类似于sys.exit(),但它不执行任何的清除工作(例如刷新缓冲区)。所以os._exit()尤其适用于退出子进程。如果程序使用sys.exit(),操作系统会回收父进程或其它子进程可能仍然需要的资源。传给os._exit()函数的参数必须是进程的退出状态。退出状态为0,表示正常终止。