You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Peter Reif <ga...@adv.magwien.gv.at> on 2001/04/26 12:17:50 UTC

IPC:Open3 does not work under mod_perl/1.25, perl5.6.0?

My program, which worked under mod_perl/1.23 and perl5.500502 does not
work anymore:

I fork a program with Open3, send it some input and catch its output.
The output is OK, but the program does not get the input:

...
    my $cgi_in = Apache::File->new;
    my $cgi_out = Apache::File->new;
    my $cgi_error = Apache::File->new;
...
   my $child = open3 ($cgi_in, $cgi_out, $cgi_error, $filename);
...
    if ($post) {
        my $len = $r->header_in ('Content-length');
        while ($len) {
            my $content;
            my $size = min ($len, 4096);
            $r->read ($content, $size);
            $r->log->debug ("content: <$content>");
            print $cgi_in $content;   # this statement does not work
            $len -= $size;
        }
    }
    close ($cgi_in);
...

IPC:Open3 works on my system, and I can print to files from my mod_perl
script. I tried the syswrite call, too.

Any comments, solutions?

Thanx
Peter

Re: IPC:Open3 does not work under mod_perl/1.25, perl5.6.0?

Posted by Peter Reif <ga...@adv.magwien.gv.at>.
Thanks! This works for me, I don't have Apache::Filter loaded, but the
effect is the same.

My new code:

my $stdin = tied *STDIN;
my $stdout = tied *STDOUT;
untie *STDIN;
untie *STDOUT;
my $child = open3 ($cgi_in, $cgi_out, $cgi_error, $filename);
tie *STDIN, ref $stdin, $stdin;
tie *STDOUT, ref $stdout, $stdout;

Re: IPC:Open3 does not work under mod_perl/1.25, perl5.6.0?

Posted by Michael J Schout <ms...@gkg.net>.
I can verify for you that this is a problem.

You wouldnt happen to be using Apache::Filter would you?

I've posted this problem at least once over the past year, and I have seen it
posted by others.  I had this porblem trying to oepn3() a pipe to gnupg and
encrypt some data. I later switched to the "GnuPG::Tie" package and had similar
problems.

After much head scratching I figured out that I was using Apache::Filter and I
needed to first untie STDIN and STDOUT before I could make things work.

My ugly hack around it basically was this:

    my ($stdin, $stdout);
    if (lc $this->request->dir_config('Filter') eq 'on') {
        # undo Apache::Filter mess.
        $stdin = tied *STDIN;
        $stdout = tied *STDOUT;
        untie *STDIN;
        untie *STDOUT;
    }
    .... use GnuPG::Tie::Encrypt to encrypt data ...
    if (lc $this->request->dir_config('Filter') eq 'on') {
        # now retie STDIN, STDOUT for Apache::Filter
        tie *STDIN, ref $stdin, $stdin;
        tie *STDOUT, ref $stdout, $stdout;
    }

I havent tried a similar solution for IPC::Open3, but you may want to try this
if you are using Apache::Filter.

Its not pretty, but it works for me :).

Mike