Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: ModPerl: ModPerl

File Descriptor used by FileHandle under mod_perl 2.0.4 - is it a perl/mod_perl bug ?

 

 

ModPerl modperl RSS feed   Index | Next | Previous | View Threaded


shibi.ns at gmail

Jun 30, 2009, 11:29 AM

Post #1 of 4 (1001 views)
Permalink
File Descriptor used by FileHandle under mod_perl 2.0.4 - is it a perl/mod_perl bug ?

Hi All,

One of my application is using following code to execute a long running
process and the control is return to the user with link to log file so that
users can monitor the progress

$req->pool->cleanup_register(sub{$self->final_process( $req,$cgi) ;});

And in final_process sub I have File open for writing the process progress

my $log = new FileHandle("process.log", "a");

When I print the $log->fileno it print FD as 0 and I have couple other log
files opened after this all of these having random numbers like 12,15 etc.
my believe is FD 0 used for STDIN . Is this is bug or aim doing something
wrong ?

My Application is running Apache/2.2.9/Mod_perl 2.04/ perl, v5.8.8 under
Red Hat Enterprise Linux release 3

Shibi Ns


sgifford at suspectclass

Jun 30, 2009, 12:07 PM

Post #2 of 4 (904 views)
Permalink
Re: File Descriptor used by FileHandle under mod_perl 2.0.4 - is it a perl/mod_perl bug ? [In reply to]

Shibi NS <shibi.ns [at] gmail> writes:

[...]

> my $log = new FileHandle("process.log", "a");
>
> When I print the $log->fileno it print FD as 0 and I have couple other log
> files opened after this all of these having random numbers like 12,15 etc. my
> believe is FD 0 used for STDIN . Is this is bug or aim doing
> something wrong ?

If you have closed FD 0, the next file opened will get that file
descriptor. If that's the case, one solution is to open /dev/null
after closing FD 0; another is to just let the FD be 0, as long as it
works.

----Scott.


shibi.ns at gmail

Jun 30, 2009, 12:39 PM

Post #3 of 4 (937 views)
Permalink
Re: File Descriptor used by FileHandle under mod_perl 2.0.4 - is it a perl/mod_perl bug ? [In reply to]

This is giving problem to me

Before I open this log file I noticed that the FD0 is points a pipe , may be
the pipe gets closed when it comes to cleanup_register

The problem arises in following scenario

1. This changes my Apache parent process FD 0 to open to this log file.
2. Later the file is got removed , but still FD 0 points to removed file.

3. Some part of my code assumes that FD0 is STDIN and tries to open this
and fails with error "Stale NFS file handle"

As you suggested if i open a dummy file handle , this issue is solved.

is my assumption is wrong "FD 0" is reserved for STDIN ?


Shibi Ns

On Wed, Jul 1, 2009 at 12:37 AM, Scott Gifford <sgifford [at] suspectclass>wrote:

> Shibi NS <shibi.ns [at] gmail> writes:
>
> [...]
>
> > my $log = new FileHandle("process.log", "a");
> >
> > When I print the $log->fileno it print FD as 0 and I have couple other
> log
> > files opened after this all of these having random numbers like 12,15
> etc. my
> > believe is FD 0 used for STDIN . Is this is bug or aim doing
> > something wrong ?
>
> If you have closed FD 0, the next file opened will get that file
> descriptor. If that's the case, one solution is to open /dev/null
> after closing FD 0; another is to just let the FD be 0, as long as it
> works.
>
> ----Scott.
>



--
--Shibi Ns--


sgifford at suspectclass

Jun 30, 2009, 1:08 PM

Post #4 of 4 (902 views)
Permalink
Re: File Descriptor used by FileHandle under mod_perl 2.0.4 - is it a perl/mod_perl bug ? [In reply to]

Shibi NS <shibi.ns [at] gmail> writes:

[...]

> is my assumption is wrong "FD 0" is reserved for STDIN ?

It's partly right: FD 0 is standard input by convention (and also by
definition) but it's not reserved or otherwise treated specially by
the OS or by Perl.

----Scott.

ModPerl modperl RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.