From 788cf89d11aef58ca0b584a5283ad9508c84408c Mon Sep 17 00:00:00 2001 From: Takuro Ashie Date: Thu, 4 Aug 2022 00:50:19 +0900 Subject: [PATCH] child_process: Plug file descriptor leak Pipes for child processes aren't closed explicitly after exiting child processes. Should't rely on GC, close immediately as soon as it isn't needed to avoid exhausting file descriptors. Signed-off-by: Takuro Ashie --- lib/fluent/plugin_helper/child_process.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/fluent/plugin_helper/child_process.rb b/lib/fluent/plugin_helper/child_process.rb index 803fddcdfd..19f1bc125c 100644 --- a/lib/fluent/plugin_helper/child_process.rb +++ b/lib/fluent/plugin_helper/child_process.rb @@ -346,6 +346,9 @@ def child_process_execute_once( if cb cb.call(process_info.exit_status) rescue nil end + process_info.readio&.close rescue nil + process_info.writeio&.close rescue nil + process_info.stderrio&.close rescue nil end thread[:_fluentd_plugin_helper_child_process_running] = true thread[:_fluentd_plugin_helper_child_process_pid] = pid