From 14782fd0b67a7f371575ee4ec4196c2a41cbadea Mon Sep 17 00:00:00 2001 From: Haroon Ahmed Date: Mon, 21 Oct 2019 13:55:33 +0100 Subject: [PATCH] Close file stream when reading pid from pidfile (#2048) * close file stream when reading pid from pidfile * add changelog --- History.md | 1 + lib/puma/control_cli.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 9366478142..8e2f1e4e37 100644 --- a/History.md +++ b/History.md @@ -8,6 +8,7 @@ * Bugfixes * Fix Errno::EINVAL when SSL is enabled and browser rejects cert (#1564) * Fix pumactl defaulting puma to development if an environment was not specified (#2035) + * Fix closing file stream when reading pid from pidfile (#2048) ## 4.2.1 / 2019-10-07 diff --git a/lib/puma/control_cli.rb b/lib/puma/control_cli.rb index 8eee72f5d3..6bad828b88 100644 --- a/lib/puma/control_cli.rb +++ b/lib/puma/control_cli.rb @@ -132,7 +132,7 @@ def prepare_configuration @pid = sf.pid elsif @pidfile # get pid from pid_file - @pid = File.open(@pidfile).gets.to_i + File.open(@pidfile) { |f| @pid = f.read.to_i } end end