From afc6cca460541d216e4ccff996ca99d7285ed884 Mon Sep 17 00:00:00 2001 From: uu59 Date: Wed, 14 Jan 2015 13:38:33 +0900 Subject: [PATCH] Ensure exit status code for detached_command method result --- app/models/fluentd/agent/local_common.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/models/fluentd/agent/local_common.rb b/app/models/fluentd/agent/local_common.rb index 231d430..73b082b 100644 --- a/app/models/fluentd/agent/local_common.rb +++ b/app/models/fluentd/agent/local_common.rb @@ -133,11 +133,12 @@ class Fluentd end def detached_command(cmd) - Bundler.with_clean_env do + thread = Bundler.with_clean_env do pid = spawn(cmd) Process.detach(pid) end - sleep 1 # NOTE/FIXME: too early return will be caused incorrect status report, "sleep 1" is a adhoc hack + thread.join + thread.value.exitstatus end end end