Subject: | No STDIN to subprocess under mod_cgi on Windows |
Date: | Mon, 29 Jul 2013 07:47:22 +0000 |
To: | <bug-IPC-Run [...] rt.cpan.org> |
From: | <larry.knibb [...] nokia.com> |
As per the discussion on perlmonks.org http://www.perlmonks.org/?node_id=1046505
I'm trying to get GraphViz2 (which uses IPC::Run) 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 an IPC::Run::run call to fdp.exe (GraphViz2.pm:608), which never returns. Apache eventually times-out and gives up trying to serve the page. The fdp.exe process runs forever (or until I kill it).
When `fdp -T svg` is called manually with no input (i.e. nothing piped to STDIN), that similarly waits forever for input; so my hypothesis is that the data that should be passed to fdp.exe's STDIN is not being sent in the mod_cgi context.
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 Files (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.
Let me know if you need any more info to debug the issue.
Cheers,
Larry