From 2135a538976bde542fd071f3b1bb168dc285937e Mon Sep 17 00:00:00 2001 From: Elijah Miller Date: Sat, 7 Feb 2009 13:20:00 -0500 Subject: [PATCH] Using block syntax of popen4 to ensure that subprocesses are properly disposed of. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes resource unavailable errors when jekyll is run with '--auto --pygments': Liquid error: Resource temporarily unavailable – fork(2) fork: Resource temporarily unavailable --- lib/jekyll/albino.rb | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/jekyll/albino.rb b/lib/jekyll/albino.rb index 5e1e6ef8..db59f2da 100644 --- a/lib/jekyll/albino.rb +++ b/lib/jekyll/albino.rb @@ -60,10 +60,13 @@ class Albino end def execute(command) - pid, stdin, stdout, stderr = Open4.popen4(command) - stdin.puts @target - stdin.close - stdout.read.strip + output = '' + Open4.popen4(command) do |pid, stdin, stdout, stderr| + stdin.puts @target + stdin.close + output = stdout.read.strip + end + output end def colorize(options = {})