martedì, aprile 29, 2008

Linux Daemon - Python sys.exit versus os._exit

Trying to daemonize a simple xmlrpc server i found some examples... let's give them credit:

W. Richard Stevens and Stephen A. Rago
Advanced Programming in the Unix Environment

Levent Karakas
http://www.enderunix.org/documents/eng/daemon.php

Devin Watson
www.netzmafia.de/skripten/unix/linux-daemon-howto.html

Chad J. Schroeder
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/278731

Some of the examples suggested to use os._exit instead of sys.exit while daemonizing a process.
The difference is quite subtle and it's fully explained in two C man pages, Python implementation of these functions follow exactly what's defined here:

man 2 _exit
man 3 exit

They're not present by default in common desktop distros...
In debian they're in manpages-dev package; think is the same on rpm based distros (not sure).

greets

Nessun commento: