about summary refs log tree commit homepage
path: root/lib/unicorn/http_server.rb
diff options
context:
space:
mode:
authorEric Wong <BOFH@YHBT.net>2022-10-01 22:57:40 +0000
committerEric Wong <bofh@yhbt.net>2022-10-04 00:53:06 +0000
commitd947cb91cf9dbd65d48e497b2605b124571f77ad (patch)
tree08514b7a6af0287f140c356ef63859fed282dff2 /lib/unicorn/http_server.rb
parente7e9e2fdf40e566a50f98d0f421892d696d6681e (diff)
downloadunicorn-d947cb91cf9dbd65d48e497b2605b124571f77ad.tar.gz
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.
Diffstat (limited to 'lib/unicorn/http_server.rb')
-rw-r--r--lib/unicorn/http_server.rb3
1 files changed, 2 insertions, 1 deletions
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