Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

IPC::Run::run not working under mod_cgi on Windows?

by larryk (Friar)
on Jul 26, 2013 at 13:02 UTC ( #1046505=perlquestion: print w/replies, xml ) Need Help??
larryk has asked for the wisdom of the Perl Monks concerning the following question:

I'm trying to get GraphViz2 (v2.14 with GraphViz 2.30) to work in a CGI script under Apache (mod_cgi) on Windows.

In a command line context it Just Works and I get the expected SVG output. In the CGI context it gets as far as the call to fdp.exe, which never returns. Apache eventually times-out and gives up trying to serve the page. The fdp.exe (sub)process runs forever (until I kill it manually) with 0% CPU and ~3MB RAM.

I can simulate the issue by calling `fdp -T svg` with no input. That similarly waits forever for input.

GraphViz2 uses IPC::Run::run to call fdp.exe and it is supposed to provide input to fdp. Since this is working on the command line, I suspect it's an issue with IPC::Run::run and mod_cgi but I can't find any comments on the web about IPC::Run::run not working under mod_cgi on Windows with regards to passing STDIN to subprocesses :|

Here's the simplest example exhibiting the issue:

#!C:\Perl64\bin\perl use strict; use warnings; use CGI; use GraphViz2; my $q = CGI->new(); print $q->header('image/svg+xml'); my $g = GraphViz2->new(global => { driver => 'C:\Program Files (x86)\G +raphviz2.30\bin\fdp.exe' }); $g->add_node(name => 'test'); $g->run(format => 'svg'); print $g->dot_output();
Any ideas?


With IPC::Run debugging on (IPCRUNDEBUG=gory) I ran the script once on the command line (which works) and again as a CGI (which doesn't) to compare the debug output.

There are no error messages or warnings and except for the PIDs, about the only difference I can see is that as a CGI, all the paths (temp file, path to executable) contain double backslashes, whereas from the command line invocation the debug output has only single backslashes:

[CGI] IPC::Run 0008 01234567890123 [#1(5888)]: cmd line: "C:\\Program +Files (x86)\\Graphviz2.30\\bin\\fdp.exe" -Tsvg [CLI] IPC::Run 0008 01234567890123 [#1(5472)]: cmd line: "C:\Program F +iles (x86)\Graphviz2.30\bin\fdp.exe" -Tsvg

The input to fdp.exe is successfully written to a temp file in both cases and the fdp.exe process is successfully started in both cases.

I guess I'll just file a bug against IPC::Run and workaround the problem by snaffling the input to fdp.exe directly from the GraphViz2 object internals (gotta love Perl :) and calling fdp.exe myself NOT using IPC::Run. *shrug*

perl -le "s,,reverse killer,e,y,rifle,lycra,,print"

Replies are listed 'Best First'.
Re: IPC::Run::run not working under mod_cgi on Windows?
by mtmcc (Hermit) on Jul 26, 2013 at 15:40 UTC
    I've never used GraphViz2, and this is probably a stupid question, but you do have IPC::Run on board, I imagine? Have you tried adding use IPC::Run;?

    Hope you find an answer!

      GraphViz2 includes IPC::Run already, otherwise the error would be similar to...
      C:\Perl\scripts>perl -MDoes::Not::Exist Can't locate Does/Not/ in @INC (@INC contains: C:/Perl64/site/ +lib C:/Perl64/lib .). BEGIN failed--compilation aborted.
      perl -le "s,,reverse killer,e,y,rifle,lycra,,print"
Re: IPC::Run::run not working under mod_cgi on Windows?
by Anonymous Monk on Jul 26, 2013 at 13:12 UTC
    ideas, 1) turn on debugging
Re: IPC::Run::run not working under mod_cgi on Windows?
by Anonymous Monk on Jul 29, 2013 at 07:37 UTC
      I'll leave that to the IPC::Run maintainer(s).

      Bug #87397.

      perl -le "s,,reverse killer,e,y,rifle,lycra,,print"

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1046505]
Approved by hdb
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2018-03-18 08:47 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (229 votes). Check out past polls.