diff options
Diffstat (limited to 'sd_daemon/notify_nonlinux.go')
-rw-r--r-- | sd_daemon/notify_nonlinux.go | 49 |
1 files changed, 2 insertions, 47 deletions
diff --git a/sd_daemon/notify_nonlinux.go b/sd_daemon/notify_nonlinux.go index 7b37a19..d09cef0 100644 --- a/sd_daemon/notify_nonlinux.go +++ b/sd_daemon/notify_nonlinux.go @@ -3,7 +3,7 @@ // // Copyright 2013, 2015 Docker, Inc. // Copyright 2014 CoreOS, Inc. -// Copyright 2015-2018 Luke Shumaker +// Copyright 2015-2019 Luke Shumaker // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -30,52 +30,7 @@ import ( "golang.org/x/sys/unix" ) -// Notification is a message to be sent to the service manager about -// state changes. -type Notification struct { - // PID specifies which process to send a notification about. - // If PID <= 0, or if the current process does not have - // privileges to send messages on behalf of other processes, - // then the message is simply sent from the current process. - PID int - - // State should contain a newline-separated list of variable - // assignments. See the documentation for sd_notify(3) for - // well-known variable assignments. - // - // https://www.freedesktop.org/software/systemd/man/sd_notify.html - State string - - // Files is a list of file descriptors to send to the service - // manager with the message. This is useful for keeping files - // open across restarts, as it enables the service manager to - // pass those files to the new process when it is restarted - // (see ListenFds). - // - // Note: The service manager will only actually store the file - // descriptors if you include "FDSTORE=1" in the state (again, - // see sd_notify(3) for well-known variable assignments). - Files []*os.File -} - -// Send sends the Notification to the service manager. -// -// If unsetEnv is true, then (regardless of whether the function call -// itself succeeds or not) it will unset the environmental variable -// NOTIFY_SOCKET, which will cause further notify operations to fail. -// -// If the service manager is not listening for notifications from this -// process tree (or a Notification has has already been send with -// unsetEnv=true), then ErrDisabled is returned. If the service -// manager appears to be listening, but there is an error sending the -// message, then that error is returned. -// -// It is generally recommended that you ignore the return value: if -// there is an error, then this is function no-op; meaning that by -// calling the function but ignoring the return value, you can easily -// support both service managers that support these notifications and -// those that do not. -func (msg Notification) Send(unsetEnv bool) error { +func (msg Notification) send(unsetEnv bool) error { if unsetEnv { defer func() { _ = os.Unsetenv("NOTIFY_SOCKET") }() } |