From d947cb91cf9dbd65d48e497b2605b124571f77ad Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 1 Oct 2022 22:57:40 +0000 Subject: http_server: detect disk-full when writing PID file While unlikely, it's possible for write(2) to return a truncated value or ENOSPC error if the device is full when writing a tiny PID file. As optimism has no place in engineering, use IO#write instead of IO#syswrite since the former will retry on truncation and raise a exception on ENOSPC. --- lib/unicorn/http_server.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/unicorn/http_server.rb b/lib/unicorn/http_server.rb index 21f2a05..3416808 100644 --- a/lib/unicorn/http_server.rb +++ b/lib/unicorn/http_server.rb @@ -187,7 +187,8 @@ class Unicorn::HttpServer rescue Errno::EEXIST retry end - fp.syswrite("#$$\n") + fp.sync = true + fp.write("#$$\n") File.rename(fp.path, path) fp.close end -- cgit v1.2.3-24-ge0c7