in reply to Apache/CGI error: "Premature end of script headers"

I'd recommend starting Apache in debug mode (where it runs in the foreground and doesn't fork) using strace/truss -f and see what Apache's doing (or not doing).

Replies are listed 'Best First'.
Re: Re: Apache/CGI error: "Premature end of script headers"
by Callum (Chaplain) on May 18, 2004 at 13:39 UTC
    Good suggestion, what I see is:

    apache starts up and does what I'd expect
    it receives a GET for the test script
    it stats test.cgi and says yep
    it looks for and finds an .htaccess file in the path, then authenticates okay
    it forks, does a couple of lwp things, a bunch of memory things, and creates a door
    one error during this, an invalid argument:

    lwp_schedctl(SC_DOOR, 0, 0x00000000) Err#22 EINVAL
    a bunch more lwp stuff, and a little more memory stuff
    then goes:
    chdir("/u/callum/public_html/cgi_test") = 0
    then 7 closes one after another, before:
    door_info(4, 0xEFFFAE70) = 0 door_call(4, 0xEFFFAE58) = 0 door_info(4, 0xEFFF9270) = 0 door_call(4, 0xEFFF9258) = 0 *** process killed ***
    And the child dies

    Then the error handling kicks in:

    Errors are written to logs
    The 500 error handler script is invoked
    lwp, memory, and door stuff, the same EINVAL error
    chdirs to the directory with the error handling script in
    a bunch of closes one after the other
    then it executes the error handling script as it should.

    So, it can stat the script and chdir to the directory, then seems to die for no reason that's evident to me.

    Time I suspect to wade line by line through the truss output I guess.