- while (1) {
- eval {
- open2(*IN, *OUT, 'otl2html -S /dev/null -T /dev/stdin');
- };
- last unless $@;
- $tries--;
- if ($tries < 1) {
- IkiWiki::debug("failed to run otl2html: $@");
- return shift;
+ my $pid;
+ do {
+ $pid = open(KID_TO_READ, "-|");
+ unless (defined $pid) {
+ $tries--;
+ if ($tries < 1) {
+ debug("failed to fork: $@");
+ return $params{content};
+ }
+ }
+ } until defined $pid;
+
+ if (! $pid) {
+ $tries=10;
+ $pid=undef;
+
+ do {
+ $pid = open(KID_TO_WRITE, "|-");
+ unless (defined $pid) {
+ $tries--;
+ if ($tries < 1) {
+ debug("failed to fork: $@");
+ print $params{content};
+ exit;
+ }
+ }
+ } until defined $pid;
+
+ if (! $pid) {
+ if (! exec 'otl2html', '-S', '/dev/null', '-T', '/dev/stdin') {
+ debug("failed to run otl2html: $@");
+ print $params{content};
+ exit;
+ }