github.com/AbhinandanKurakure/podman/v3@v3.4.10/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  	return true
    29  }