문제

How can I query if a service (dnsmasq) is running, in C?

도움이 되었습니까?

해결책

According to the dnsmasq man page, by default it writes a pid file to /var/run/dnsmasq.pid. This file will be a text file that contains an integer representing the process ID. Open the file, read the integer, and call kill(pid, 0) to see whether the process is alive at that pid. (Although checking for PID existence isn't guaranteed to not find some other process running at that PID, it's usually good enough.)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top