Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 20 Sep 1996 17:27:58 -0700 (PDT)
From:      Jaye Mathisen <mrcpu@schizo.cdsnet.net>
To:        hackers@freebsd.org
Subject:   Hmmm, command-line vs CGI execution of perl 5.003 app and FreeBSD.
Message-ID:  <199609210027.RAA06899@schizo.cdsnet.net>

next in thread | raw e-mail | index | archive | help


OK, stumper time.

Perl 5.003, FreeBSD 2.2-current, Apache 1.1.1 with xssi,php/fi, and Netscape
Server 1.0.



Under Netscape 1.1 server, I have a perl CGI script that runs fine.  I take
the same script on the same box and run it under Apache, and I get "Premature
end of Script Headers".

So I go through the script with use strict, and -w, and no errors.

I tried $|=1, and various incarnations of "select" to see if it was an 
unbuffered output problem, but to no avail.

If I run the script from the command line, the generated output looks
just peachy, and other than stripping off the initial 
Content-type: text/html\n\n mumbo-jumbo, when put in a .html file, displays
fine.

running the script with redirected stdout/stderr shows no output on anything
other than stdout.

So I muck around in the util-script.c file for apache and throw in some
debugging, and add the following after the log message for the error message:

            fprintf(stderr,"w -> %s, *f -> %s, feof= %d, ferror = %d, fileno = %
d\n",w,f,feof(f), ferror(f), fileno(f)); 

	(Ignoring my braindamage for *f, but I didn't feel like re-compiling for
the example)


And lo and behold:

 w -> , *f -> , feof= 1, ferror = 0, fileno = 9


So it looks as if somehow the fd's are getting munged?  The question, is
this a perl/Apache interaction problem?  Is there something in Perl I should
be doing to make this work properly?

This is the same box that had op/exec failing in the perl test, and I notice
that perl 5.003_002 won't Configure on it, it fails in Configure with a problem
with file descriptor 4.

The script has a little database stuff, but none of those modules generate any 
output.

Been doing all the scripting with the Netscape server, and never had this 
problem other than throwing the $|=1 at the top of every script.

I'm starting to think it's a FreeBSD problem, but thought I'd hit the experts
first.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199609210027.RAA06899>