Bringing Linux pidfd to Ruby
summary
Argues that Linux pidfd gives stable, race-free process references and fixes pid reuse and signal-race bugs; implements pidfd in Ruby via FFI calling the pidfd syscall family, wraps descriptors as IO, and uses them to send signals and reap children. Shows a reproduction where aggressive forking hits the same PID after 348 attempts. Deploys the pidfd-backed supervisor in production but notes limits: Linux 5.3+, same PID namespace only, no cross-container monitoring, and pidfd is an edge-case optimization rather than a default.
AI-written summary · about
chapters (14)
- 0:00Introduction and speaker intro
- 1:23Ruby process management challenges
- 5:17Ruby threads vs processes in background jobs
- 8:56What are Linux pidfds
- 12:11Pid reuse race condition risks
- 13:56Signal race conditions in Ruby
- 16:05Process tree limitations in Ruby
- 18:16How Linux pidfds work
- 21:07Implementing pidfds in Ruby with FFI
- 22:53Using pidfds for process monitoring
- 24:37Pidfd limitations and constraints
- 25:58When to use pidfds in Ruby
- 27:03Future plans for pidfd in Ruby
- 28:31Q&A and closing remarks








