"fork and exit" needed?
nick at craig-wood.com
Tue Nov 28 15:30:03 CET 2006
Dennis Lee Bieber <wlfraed at ix.netcom.com> wrote:
> On Tue, 28 Nov 2006 04:30:09 -0600, Nick Craig-Wood
> <nick at craig-wood.com> declaimed the following in comp.lang.python:
> > If you run this
> > import os,sys,time
> > print os.getpid()
> > sys.stdout = open(os.devnull, 'w')
> > time.sleep(60)
> > It prints its pid.
> I would hope so, as you performed the print BEFORE reassigning
That is what I intended. I wanted the pid to look in /proc/<pid>/fd
to see what file descriptors were really open.
> import os,sys,time
> print "pre:", os.getpid()
> sys.stdout = open(os.devnull, 'w')
> print "post:", os.getpid()
> (Granted, I'm on WinXP; I also suspect the original stdout is still open
> in the background, maybe dualled with stderr?)
Yes that is the point - the original stdout is still open.
I don't think this discussion is relevant to windows though - windows
has its own way of making daemons.
Nick Craig-Wood <nick at craig-wood.com> -- http://www.craig-wood.com/nick
More information about the Python-list