From: roy at popmail.med.nyu.edu (Roy Smith)
Date: Tue, 13 Apr 1999 11:55:36 -0400
Subject: forking + stdout = confusion
References: <RUgQ2.31$Oq4.32657@newsfeed.avtel.net> <87n20caldg.fsf@spock.localnet.de>
Message-ID: <roy-1304991155360001@qwerky.med.nyu.edu>
X-UID: 1334                                                  

Carsten Schabacker <cs at spock.rhein-neckar.de> wrote:
> No, the child and the parent share the SAME filedescriptors.  This is true
> for ALL open files!  So if you don't need the descriptors in a child or a
> parent you should close them.  
> 
> Apache waits for the end of the file, so all processes (parents and
> childs) must close the file!

When doing a similar thing a while ago, I had similar problems :-)  I
eventually found that in addition to doing sys.stdout.close(), I had to do
os.close(1) to make sure the fd really got closed.

I'm still not sure I understand what was going on.  I know that
sys.__stdout__ contains a copy of sys.stdout, so at first I figured that
doing both sys.stdout.close() and sys.__stdout__.close() would do the
trick, but it didn't, but os.close(1) did.

-- 
Roy Smith <roy at popmail.med.nyu.edu>
New York University School of Medicine





