According to the dnsmasq man page , by default it writes the pid file to /var/run/dnsmasq.pid. This file will be a text file that contains an integer representing the process identifier. Open the file, read the integer and call kill(pid, 0)to find out if this process is alive in this pid. (Although checking for the existence of a PID does not guarantee that it will not find any other process running on that PID, it is usually good enough.)
source
share