github.com/containers/podman/v2@v2.2.2-0.20210501105131-c1e07d070c4c/pkg/systemd/activation.go (about) 1 package systemd 2 3 import ( 4 "os" 5 "strconv" 6 ) 7 8 // SocketActivated determine if podman is running under the socket activation protocol 9 // Criteria is based on the expectations of "github.com/coreos/go-systemd/v22/activation" 10 func SocketActivated() bool { 11 pid, found := os.LookupEnv("LISTEN_PID") 12 if !found { 13 return false 14 } 15 p, err := strconv.Atoi(pid) 16 if err != nil || p != os.Getpid() { 17 return false 18 } 19 20 fds, found := os.LookupEnv("LISTEN_FDS") 21 if !found { 22 return false 23 } 24 nfds, err := strconv.Atoi(fds) 25 if err != nil || nfds == 0 { 26 return false 27 } 28 29 // "github.com/coreos/go-systemd/v22/activation" will use and validate this variable's 30 // value. We're just providing a fast fail 31 if _, found = os.LookupEnv("LISTEN_FDNAMES"); !found { 32 return false 33 } 34 return true 35 }