Request if service is running

How can I ask if the service (dnsmasq) is running in C?

+3
source share
1 answer

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.)

+4
source

Source: https://habr.com/ru/post/1767817/


All Articles