From: clarence at silcom.com (Clarence Gardner)
Date: Fri, 16 Apr 1999 15:04:12 GMT
Subject: forking + stdout = confusion
References: <m3btgrnqif.fsf@atrus.jesus.cam.ac.uk> <001d01be87b5$8b3529a0$ada22299@tim>
Message-ID: <MjIR2.63$kw6.87104@newsfeed.avtel.net>
Content-Length: 1644
X-UID: 1575                                                  

Tim Peters (tim_one at email.msn.com), as usual, knew the answer:
: It doesn't matter, though, because unlike file objects you create with
: "open", Python won't close the file descriptor underlying the default
: binding for sys.stdout (or .stdin or .stderr) even if all references do go
: away.  Those three file objects are initialized specially (in _PySys_Init).

I promise this will be my last posting in this thread :)
Tim:
    Thanks!

Carsten, et al.:
    The Apache, CERN and Netscape HTTP servers (at least for Unix) treat
    any CGI program differently if its name begins with 'nph-'.  Normally,
    stdout in a CGI is a pipe into the web server, which copies the data
    to the client.  Before the data, however, it also includes the HTTP
    response headers (though it requires you to supply the Content-Type).
    It may also buffer the entire response so that it can include a
    Content-Length.

    Technically, the difference in the NPH environment is that the server
    does not add any headers, so the entire HTTP response must be provided
    by the CGI program.  (One of the reasons NPH is necessary is if you
    want to provide an unusual HTTP response code.  The server normally
    takes care of Success and, if you provide a Location: or URI: header,
    Redirection statuses.)  (NPH supposedly means 'non parsed headers'.)

    In practice, the server also does away with the buffering in the NPH
    case, and sets the stdout for the CGI program to be the connection to
    the client.

-- 
-=-=-=-=-=-=-=-=
Clarence Gardner
AvTel Communications
Software Products and Services Division
clarence at avtel.com




