程序如何检测它是否作为 systemd 守护进程运行? [英] How can a program detect if it is running as a systemd daemon?
本文介绍了程序如何检测它是否作为 systemd 守护进程运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在程序中是否有任何方法可以检测到systemd作为守护程序运行?
Is there any way to detect in a program that it is run by systemd as a daemon?
系统API
sd_booted()
用于检测整个系统是否由systemd引导,但未说明程序本身.
is used to detected if the whole system is booted by systemd, but says nothing about the program itself.
谢谢
推荐答案
获取父进程ID,并查看该进程是否为 systemd
.
Get the parent process id and see whether that process is systemd
.
这篇关于程序如何检测它是否作为 systemd 守护进程运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文