I made this because I'm not comfortable relying only on a check of the existence of a process associated with the PID contained in the PID file. I know that exhausting the PID stack is highly unlikely but it's not impossible and I like to make fewer assumptions.
You can spawn Puma with ./spawn.sh
and in another shell, simulate a stop with ./stop.sh
.
After the Puma process stops, a "gate file" gets created, simulating the notification of the end of the process.
Using the gate file it's possible to wait for its creation right after having sent the SIGTERM signal but other type of notifications are possible.
I tested this code on OpenBSD 6.1 amd64.