mirror of
https://github.com/NixOS/nix
synced 2025-06-29 06:21:14 +02:00
getEnv(): Return std::optional
This allows distinguishing between an empty value and no value.
This commit is contained in:
parent
fd900c45b5
commit
ba87b08f85
17 changed files with 60 additions and 63 deletions
|
@ -161,8 +161,9 @@ static void daemonLoop(char * * argv)
|
|||
AutoCloseFD fdSocket;
|
||||
|
||||
/* Handle socket-based activation by systemd. */
|
||||
if (getEnv("LISTEN_FDS") != "") {
|
||||
if (getEnv("LISTEN_PID") != std::to_string(getpid()) || getEnv("LISTEN_FDS") != "1")
|
||||
auto listenFds = getEnv("LISTEN_FDS");
|
||||
if (listenFds) {
|
||||
if (getEnv("LISTEN_PID") != std::to_string(getpid()) || listenFds != "1")
|
||||
throw Error("unexpected systemd environment variables");
|
||||
fdSocket = SD_LISTEN_FDS_START;
|
||||
closeOnExec(fdSocket.get());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue