improve systemd or docker detection

This commit is contained in:
Alireza Ahmadi
2024-10-29 13:14:25 +01:00
parent 1d46d72186
commit 282e244517
4 changed files with 14 additions and 4 deletions
+9
View File
@@ -79,3 +79,12 @@ func GetDefaultConfig() string {
func GetEnvApi() string {
return os.Getenv("SINGBOX_API")
}
func IsSystemd() bool {
pid := os.Getppid()
cmdline, err := os.ReadFile(fmt.Sprintf("/proc/%d/comm", pid))
if err != nil {
return false
}
return string(cmdline) == "systemd\n"
}