Python without a tty
Hegedüs, Ervin
airween at gmail.com
Mon Oct 3 02:10:57 EDT 2011
hello,
On Mon, Oct 03, 2011 at 04:37:43AM +0000, Steven D'Aprano wrote:
>
> I wanted to ensure that it would do the right thing when run without a tty,
> such as from a cron job.
If you fork() your process, then it will also loose the tty...
import os
import sys
try:
pid = os.fork()
if pid > 0:
sys.exit(0)
except OSError, e:
sys.exit(1)
os.chdir("/")
os.setsid()
os.umask(0)
a.
More information about the Python-list
mailing list