From c51d0a543e42087f3a5bfbcd89cebeff165df2f9 Mon Sep 17 00:00:00 2001 From: "Ryan S. Burgoyne" Date: Mon, 25 Feb 2013 08:39:31 -0700 Subject: [PATCH] Added handling to the new open2 process to make sure it terminated --- pandoc.pm | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) 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)); -- 2.39.2