Failed to dup STDIN: Bad file descriptor.

Failed to dup STDIN: Bad file descriptor.

am 19.11.2008 15:14:30 von Rashmi Badan

Hi,

I load mod_perl into a customized Apache on Windows but when I send a
simple request (http://host:port/perl/testperl.pl - testperl.pl just
prints a simple message) Apache dies and throws the following message
in the error log

Failed to dup STDIN: Bad file descriptor.

I see that this is coming from modperl_io_perlio_override_stdin() in
modperl_io.c but do not know why. If I try loading the same module
into plain Apache I don't seem to hit this problem and am able to
access the script just fine. I would appreciate it if someone could
give me some pointers to debug this issue.

Versions used :
Apache 2.2.9
mod_perl 2.0.4
perl 5.10

mod_perl.conf.
------------------------------------------------------------ -
LoadFile ${PERL_PATH}/bin/perl510.dll
LoadModule perl_module modules/mod_perl.so

#
# Setup mod_perl to handle perl cgi scripts from the cgi-bin directory
#


Alias /perl/ "${APACHE_HOME}/cgi-bin/"
PerlModule ModPerl::Registry
PerlSwitches -I${APACHE_HOME}/mod_perl/lib


SetHandler perl-script
AddHandler perl-script .pl
PerlResponseHandler ModPerl::Registry
PerlOptions +ParseHeaders
Options +ExecCGI



------------------------------------------------------------ -

Thanks,
Rashmi

Re: Failed to dup STDIN: Bad file descriptor.

am 19.11.2008 17:28:37 von Shibi NS

------=_Part_92593_28185167.1227112117537
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

I believe fd 0 and/or fd 1 are closed in Apache 2 which might be causing the
issue.

I had the similar kid of issue - i used following code to fix it

$fileno = fileno(STDIN);

if ( defined($fileno) and $fileno != 0)
{
$stdin = IO::Handle->new();
$stdin->fdopen(0, "w") ||
die "Unable to open STDIN using fd 0: $!\n";
}
else
{
$stdin = \*STDIN;
}


On Wed, Nov 19, 2008 at 7:44 PM, Rashmi Badan wrote:

> Hi,
>
> I load mod_perl into a customized Apache on Windows but when I send a
> simple request (http://host:port/perl/testperl.pl - testperl.pl just
> prints a simple message) Apache dies and throws the following message
> in the error log
>
> Failed to dup STDIN: Bad file descriptor.
>
> I see that this is coming from modperl_io_perlio_override_stdin() in
> modperl_io.c but do not know why. If I try loading the same module
> into plain Apache I don't seem to hit this problem and am able to
> access the script just fine. I would appreciate it if someone could
> give me some pointers to debug this issue.
>
> Versions used :
> Apache 2.2.9
> mod_perl 2.0.4
> perl 5.10
>
> mod_perl.conf.
> ------------------------------------------------------------ -
> LoadFile ${PERL_PATH}/bin/perl510.dll
> LoadModule perl_module modules/mod_perl.so
>
> #
> # Setup mod_perl to handle perl cgi scripts from the cgi-bin directory
> #
>
>
> Alias /perl/ "${APACHE_HOME}/cgi-bin/"
> PerlModule ModPerl::Registry
> PerlSwitches -I${APACHE_HOME}/mod_perl/lib
>
>
> SetHandler perl-script
> AddHandler perl-script .pl
> PerlResponseHandler ModPerl::Registry
> PerlOptions +ParseHeaders
> Options +ExecCGI
>

>

>

> ------------------------------------------------------------ -
>
> Thanks,
> Rashmi
>



--
--Shibi Ns--

------=_Part_92593_28185167.1227112117537
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

I believe fd 0 and/or fd 1 are closed in Apache 2 which might be causing the issue.

I had the similar kid of issue - i used  following code to fix it

        $fileno = fileno(STDIN);

        if ( defined($fileno) and $fileno != 0)


        {
            $stdin = IO::Handle->new();
            $stdin->fdopen(0, "w") ||
                die "Unable to open STDIN using fd 0: $!\n";
        }
        else
        {


            $stdin = \*STDIN;
        }


On Wed, Nov 19, 2008 at 7:44 PM, Rashmi Badan <> wrote:

Hi,



I load mod_perl into a customized Apache on Windows but when I send a

simple request (http://host:port/perl/testperl.pl - testperl.pl just

prints a simple message) Apache dies and throws the following message

in the error log



Failed to dup STDIN: Bad file descriptor.



I see that this is coming from modperl_io_perlio_override_stdin() in

modperl_io.c but do not know why. If I try loading the same module

into plain Apache I don't seem to hit this problem and am able to

access the script just fine. I would appreciate it if someone could

give me some pointers to debug this issue.



Versions used :

Apache 2.2.9

mod_perl 2.0.4

perl 5.10



mod_perl.conf.

------------------------------------------------------------ -

LoadFile  ${PERL_PATH}/bin/perl510.dll

LoadModule perl_module modules/mod_perl.so



 #

 # Setup mod_perl to handle perl cgi scripts from the cgi-bin directory

 #

<IfModule mod_alias.c>

 <IfModule mod_perl.c>

   Alias /perl/ "${APACHE_HOME}/cgi-bin/"

   PerlModule ModPerl::Registry

   PerlSwitches -I${APACHE_HOME}/mod_perl/lib



   <Location /perl/>

     SetHandler perl-script

     AddHandler perl-script .pl

     PerlResponseHandler ModPerl::Registry

     PerlOptions +ParseHeaders

     Options +ExecCGI

   </Location>

 </IfModule>

</IfModule>

------------------------------------------------------------ -



Thanks,

Rashmi




--
--Shibi Ns--


------=_Part_92593_28185167.1227112117537--

Re: Failed to dup STDIN: Bad file descriptor.

am 19.11.2008 17:55:58 von Shibi NS

------=_Part_93144_5789363.1227113758611
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

sorry i meant mod_perl not Apache

On Wed, Nov 19, 2008 at 9:58 PM, Shibi NS wrote:

> I believe fd 0 and/or fd 1 are closed in Apache 2 which might be causing
> the issue.
>
> I had the similar kid of issue - i used following code to fix it
>
> $fileno = fileno(STDIN);
>
> if ( defined($fileno) and $fileno != 0)
> {
> $stdin = IO::Handle->new();
> $stdin->fdopen(0, "w") ||
> die "Unable to open STDIN using fd 0: $!\n";
> }
> else
> {
> $stdin = \*STDIN;
> }
>
>
> On Wed, Nov 19, 2008 at 7:44 PM, Rashmi Badan wrote:
>
>> Hi,
>>
>> I load mod_perl into a customized Apache on Windows but when I send a
>> simple request (http://host:port/perl/testperl.pl - testperl.pl just
>> prints a simple message) Apache dies and throws the following message
>> in the error log
>>
>> Failed to dup STDIN: Bad file descriptor.
>>
>> I see that this is coming from modperl_io_perlio_override_stdin() in
>> modperl_io.c but do not know why. If I try loading the same module
>> into plain Apache I don't seem to hit this problem and am able to
>> access the script just fine. I would appreciate it if someone could
>> give me some pointers to debug this issue.
>>
>> Versions used :
>> Apache 2.2.9
>> mod_perl 2.0.4
>> perl 5.10
>>
>> mod_perl.conf.
>> ------------------------------------------------------------ -
>> LoadFile ${PERL_PATH}/bin/perl510.dll
>> LoadModule perl_module modules/mod_perl.so
>>
>> #
>> # Setup mod_perl to handle perl cgi scripts from the cgi-bin directory
>> #
>>
>>
>> Alias /perl/ "${APACHE_HOME}/cgi-bin/"
>> PerlModule ModPerl::Registry
>> PerlSwitches -I${APACHE_HOME}/mod_perl/lib
>>
>>
>> SetHandler perl-script
>> AddHandler perl-script .pl
>> PerlResponseHandler ModPerl::Registry
>> PerlOptions +ParseHeaders
>> Options +ExecCGI
>>

>>

>>

>> ------------------------------------------------------------ -
>>
>> Thanks,
>> Rashmi
>>
>
>
>
> --
> --Shibi Ns--
>



--
--Shibi Ns--

------=_Part_93144_5789363.1227113758611
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

sorry i meant mod_perl not Apache

On Wed, Nov 19, 2008 at 9:58 PM, Shibi NS <> wrote:

I believe fd 0 and/or fd 1 are closed in Apache 2 which might be causing the issue.


I had the similar kid of issue - i used  following code to fix it

        $fileno = fileno(STDIN);


        if ( defined($fileno) and $fileno != 0)


        {
            $stdin = IO::Handle->new();
            $stdin->fdopen(0, "w") ||
                die "Unable to open STDIN using fd 0: $!\n";
        }
        else
        {



            $stdin = \*STDIN;
        }


On Wed, Nov 19, 2008 at 7:44 PM, Rashmi Badan <> wrote:


Hi,



I load mod_perl into a customized Apache on Windows but when I send a

simple request (http://host:port/perl/testperl.pl - testperl.pl just

prints a simple message) Apache dies and throws the following message

in the error log



Failed to dup STDIN: Bad file descriptor.



I see that this is coming from modperl_io_perlio_override_stdin() in

modperl_io.c but do not know why. If I try loading the same module

into plain Apache I don't seem to hit this problem and am able to

access the script just fine. I would appreciate it if someone could

give me some pointers to debug this issue.



Versions used :

Apache 2.2.9

mod_perl 2.0.4

perl 5.10



mod_perl.conf.

------------------------------------------------------------ -

LoadFile  ${PERL_PATH}/bin/perl510.dll

LoadModule perl_module modules/mod_perl.so



 #

 # Setup mod_perl to handle perl cgi scripts from the cgi-bin directory

 #

<IfModule mod_alias.c>

 <IfModule mod_perl.c>

   Alias /perl/ "${APACHE_HOME}/cgi-bin/"

   PerlModule ModPerl::Registry

   PerlSwitches -I${APACHE_HOME}/mod_perl/lib



   <Location /perl/>

     SetHandler perl-script

     AddHandler perl-script .pl

     PerlResponseHandler ModPerl::Registry

     PerlOptions +ParseHeaders

     Options +ExecCGI

   </Location>

 </IfModule>

</IfModule>

------------------------------------------------------------ -



Thanks,

Rashmi




--
--Shibi Ns--




--
--Shibi Ns--


------=_Part_93144_5789363.1227113758611--

Re: Failed to dup STDIN: Bad file descriptor.

am 19.11.2008 17:56:48 von Rashmi Badan

Yes, Apache closes the STDIN on startup.
Thanks for the code snippet, but this does not address my problem. I
am not looking at fixing the perl script as I don't think the problem
lies there. The problem perhaps lies in my customized Apache - I'm not
sure about it.

Rgds,
Rashmi

On Wed, Nov 19, 2008 at 9:58 PM, Shibi NS wrote:
> I believe fd 0 and/or fd 1 are closed in Apache 2 which might be causing the
> issue.
>
> I had the similar kid of issue - i used following code to fix it
>
> $fileno = fileno(STDIN);
>
> if ( defined($fileno) and $fileno != 0)
> {
> $stdin = IO::Handle->new();
> $stdin->fdopen(0, "w") ||
> die "Unable to open STDIN using fd 0: $!\n";
> }
> else
> {
> $stdin = \*STDIN;
> }
>
>
> On Wed, Nov 19, 2008 at 7:44 PM, Rashmi Badan
> wrote:
>>
>> Hi,
>>
>> I load mod_perl into a customized Apache on Windows but when I send a
>> simple request (http://host:port/perl/testperl.pl - testperl.pl just
>> prints a simple message) Apache dies and throws the following message
>> in the error log
>>
>> Failed to dup STDIN: Bad file descriptor.
>>
>> I see that this is coming from modperl_io_perlio_override_stdin() in
>> modperl_io.c but do not know why. If I try loading the same module
>> into plain Apache I don't seem to hit this problem and am able to
>> access the script just fine. I would appreciate it if someone could
>> give me some pointers to debug this issue.
>>
>> Versions used :
>> Apache 2.2.9
>> mod_perl 2.0.4
>> perl 5.10
>>
>> mod_perl.conf.
>> ------------------------------------------------------------ -
>> LoadFile ${PERL_PATH}/bin/perl510.dll
>> LoadModule perl_module modules/mod_perl.so
>>
>> #
>> # Setup mod_perl to handle perl cgi scripts from the cgi-bin directory
>> #
>>
>>
>> Alias /perl/ "${APACHE_HOME}/cgi-bin/"
>> PerlModule ModPerl::Registry
>> PerlSwitches -I${APACHE_HOME}/mod_perl/lib
>>
>>
>> SetHandler perl-script
>> AddHandler perl-script .pl
>> PerlResponseHandler ModPerl::Registry
>> PerlOptions +ParseHeaders
>> Options +ExecCGI
>>

>>

>>

>> ------------------------------------------------------------ -
>>
>> Thanks,
>> Rashmi
>
>
>
> --
> --Shibi Ns--
>