Ah, that would be a problem if Apache had a handler to close the FILE*

As the handler is for the FILE* (I saw by reading the code) We could
work around this by doing

  freopen("/dev/null",mode,fp);

after the dup has been done. That would result in the FILE* apache has a cleanup
handler on still being valid, and only one fd open to the pipe to the subprocess

Graham.

On Mon, Aug 19, 2002 at 09:43:39AM -0700, [EMAIL PROTECTED] wrote:
> hi graham,
> sorry for the delay.  i haven't touched this module is so long, but recall 
> the dup is because apache registers a cleanup to close the file, so perl 
> needs its own copy.  could be that there's a better way.  you might want 
> to resend to [EMAIL PROTECTED], stas bekman has implemented the 2.0 
> version of this module and might have some more insight.
> 
> On Fri, 19 Jul 2002, Graham Barr wrote:
> 
> > Doug, In SubProcess.xs you have
> > 
> > static FILE *io_dup(FILE *fp, char *mode)
> > {
> >     int fd = PerlIO_fileno(fp);
> >     FILE *retval;
> > 
> >     fd = PerlLIO_dup(fd);
> >     if (!(retval = PerlIO_fdopen(fd, mode))) {
> >         PerlLIO_close(fd);
> >         croak("fdopen failed!");
> >     }
> > 
> >     return retval;
> > }
> > 
> > I was wondering what the purpose was of the line
> > 
> >     fd = PerlLIO_dup(fd);
> > 
> > I was having a problem with the spawned process seeing EOF, but
> > if I removed this line then it saw it. So I was wondering if
> > there was a specific reason you dup'd the fd.
> > 
> > However, even though with this my code sees EOF. Sometimes it
> > does not work. I have a script that does
> > 
> >   #!/usr/bin/perl
> >   open(STDERR,">/tmp/gmb");
> >   select STDERR;
> >   $|=1;
> >   warn "$$ $_\n" for @ARGV;
> >   while(<STDIN>) {
> >     warn $_;
> >   }
> >   warn "DONE";
> > 
> > Most times in /tmp/gmb I see everything, but sometimes the file
> > is empty. The fact it is there, but empty, makes me think the process
> > gets killed, do you know if thats the case and why ?
> > 
> > Regards,
> > Graham.
> > 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to