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?

Update:

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*

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

In reply to IPC::Run::run not working under mod_cgi on Windows? by larryk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.