forking + stdout = confusion

Clarence Gardner clarence at silcom.com
Fri Apr 16 11:04:12 EDT 1999


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




More information about the Python-list mailing list