This article features the very useful program "checkrestart" which is OpenBSD specific. The purpose of checkrestart is to display which programs and their according PID for which the binaries doesn't exist anymore.
Why would their binary be absent? The obvious case is that the program was removed, but what it is really good at, is when you upgrade a package with running binaries, the old binary is deleted and the new binary installed. In that case, you will have to stop all the running binaries and restart them. Hence the name "checkrestart".
Installing it is as simple as running pkg_add checkrestart
This is simple too, when you run checkrestart, you will have a list of PID numbers with the binary name.
For example, on my system, checkrestart gives me information about what programs got updated that I should restart to run the new binary.
69575 lagrange 16033 lagrange 9664 lagrange 77211 dhcpleased 6134 dhcpleased 21860 dhcpleased
Real world usage §
If you run OpenBSD -stable, you will want to use checkrestart after running pkg_add -u. After a package update, most often related to daemons, you will have to restart the related services.
On my server, in my daily script updating packages and running syspatch, I use it to automatically restart some services.
checkrestart | grep php && rcctl restart php-fpm checkrestart | grep postgres && rcctl restart postgresql checkrestart | grep nginx && rcctl restart nginx
Other Operating System §
I've been told that checkrestart is also available on FreeBSD as a package! The output may differ but the use is the same.
On Linux, a similar tool exists under the name "needrestart", at least on Debian and Gentoo.