1
0
mirror of https://github.com/containers/podman.git synced 2026-02-05 15:45:08 +01:00
Files
podman/pkg/systemd/activation.go

30 lines
579 B
Go
Raw Permalink Normal View History

package systemd
import (
"os"
"strconv"
)
// SocketActivated determine if podman is running under the socket activation protocol
// Criteria is based on the expectations of "github.com/coreos/go-systemd/v22/activation"
func SocketActivated() bool {
pid, found := os.LookupEnv("LISTEN_PID")
if !found {
return false
}
p, err := strconv.Atoi(pid)
if err != nil || p != os.Getpid() {
return false
}
fds, found := os.LookupEnv("LISTEN_FDS")
if !found {
return false
}
nfds, err := strconv.Atoi(fds)
if err != nil || nfds == 0 {
return false
}
return true
}