From owner-freebsd-hackers Fri Sep 20 17:32:50 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id RAA05404 for hackers-outgoing; Fri, 20 Sep 1996 17:32:50 -0700 (PDT) Received: from mail.crl.com (mail.crl.com [165.113.1.22]) by freefall.freebsd.org (8.7.5/8.7.3) with SMTP id RAA05387 for ; Fri, 20 Sep 1996 17:32:48 -0700 (PDT) Received: from schizo.cdsnet.net by mail.crl.com with SMTP id AA25955 (5.65c/IDA-1.5 for ); Fri, 20 Sep 1996 17:33:18 -0700 Received: (from mrcpu@localhost) by schizo.cdsnet.net (8.7.5/8.7.3) id RAA06931; Fri, 20 Sep 1996 17:30:15 -0700 (PDT) Date: Fri, 20 Sep 1996 17:30:15 -0700 (PDT) From: Jaye Mathisen Message-Id: <199609210030.RAA06931@schizo.cdsnet.net> To: hackers@freebsd.org X-Also-Posted-To: comp.lang.perl.misc Subject: Hmmm, command-line vs CGI execution of perl 5.003 app and FreeBSD. Organization: CDS Internet Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk 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.