From: Ryan S. Burgoyne Date: Mon, 25 Feb 2013 15:39:31 +0000 (-0700) Subject: Added handling to the new open2 process to make sure it terminated X-Git-Url: https://git.g-eek.se/?a=commitdiff_plain;h=c51d0a543e42087f3a5bfbcd89cebeff165df2f9;p=ikiwiki-pandoc.git Added handling to the new open2 process to make sure it terminated --- diff --git a/pandoc.pm b/pandoc.pm index dbf04ed..17a0013 100644 --- a/pandoc.pm +++ b/pandoc.pm @@ -188,18 +188,20 @@ sub htmlize ($@) { # Convert to intermediate JSON format so that the title block # can be parsed out - my $pid = open2(*JSON_OUT, *PANDOC_OUT, $command, + my $to_json_pid = open2(*JSON_OUT, *PANDOC_OUT, $command, '-f', $format, '-t', 'json', @args); + error("Unable to open $command") unless $to_json_pid; + # $ENV{"LC_ALL"} = "en_US.UTF-8"; - $pid = open2(*PANDOC_IN, *JSON_IN, $command, + my $to_html_pid = open2(*PANDOC_IN, *JSON_IN, $command, '-f', 'json', '-t', 'html', @args); - error("Unable to open $command") unless $pid; + error("Unable to open $command") unless $to_html_pid; # Workaround for perl bug (#376329) require Encode; @@ -211,13 +213,15 @@ sub htmlize ($@) { my $json_content = ; close JSON_OUT; + waitpid $to_json_pid, 0; + print JSON_IN $json_content; close JSON_IN; my @html = ; close PANDOC_IN; - waitpid $pid, 0; + waitpid $to_html_pid, 0; $content = Encode::decode_utf8(join('', @html));