I believe the correct solution is to cache the value:

```ruby
   def pid
-    File.read(pidfile).to_i
+    @pid ||= File.read(pidfile).to_i
   end
```