File Descriptor used by FileHandle under mod_perl 2.0.4 - is it a

File Descriptor used by FileHandle under mod_perl 2.0.4 - is it a

am 30.06.2009 20:29:11 von Shibi NS

--0016364ef4d6a4afef046d94fb19
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

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

--0016364ef4d6a4afef046d94fb19
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Hi All,

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

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


And in final_process sub I have File open for writing the process progr=
ess

my $log =3D new FileHandle("process.log", "a&quo=
t;);

When I print the=A0 $log->fileno it print FD as 0=A0 and I h=
ave couple other log files opened after this all of these having random num=
bers 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 unde=
r=A0 Red Hat Enterprise Linux release 3

Shibi Ns


--0016364ef4d6a4afef046d94fb19--

Re: File Descriptor used by FileHandle under mod_perl 2.0.4 - is ita perl/mod_perl bug ?

am 30.06.2009 21:07:25 von Scott Gifford

Shibi NS 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.

Re: File Descriptor used by FileHandle under mod_perl 2.0.4 - is it a

am 30.06.2009 21:39:33 von Shibi NS

--0016360e3b3c4a66e3046d95f77c
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

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 wrote:

> Shibi NS 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--

--0016360e3b3c4a66e3046d95f77c
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

This is giving problem to me

Before I open this log file I noticed t=
hat 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=A0 to open to this log f=
    ile.
  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 a=
    nd 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 so=
lved.=A0

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

=A0
Shibi Ns

On Wed, =
Jul 1, 2009 at 12:37 AM, Scott Gifford < lto:sgifford@suspectclass.com">sgifford@suspectclass.com> wro=
te:

204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Shibi NS < ref=3D"mailto:shibi.ns@gmail.com">shibi.ns@gmail.com> writes:



[...]



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

> When I print the =A0$log->fileno it print FD as 0 =A0and I have cou=
ple 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. =A0If 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--


--0016360e3b3c4a66e3046d95f77c--

Re: File Descriptor used by FileHandle under mod_perl 2.0.4 - is ita perl/mod_perl bug ?

am 30.06.2009 22:08:45 von Scott Gifford

Shibi NS 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.