summaryrefslogtreecommitdiff
path: root/sd_daemon/notify.go
diff options
context:
space:
mode:
Diffstat (limited to 'sd_daemon/notify.go')
-rw-r--r--sd_daemon/notify.go23
1 files changed, 17 insertions, 6 deletions
diff --git a/sd_daemon/notify.go b/sd_daemon/notify.go
index a038f54..8fce6da 100644
--- a/sd_daemon/notify.go
+++ b/sd_daemon/notify.go
@@ -14,7 +14,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package sd_daemon
+package sd
import (
"errors"
@@ -22,11 +22,22 @@ import (
"os"
)
-// ErrNotifyNoSocket is an error returned if no socket was specified.
-var ErrNotifyNoSocket = errors.New("No socket")
+// errNotifyNoSocket is an error returned if no socket was specified.
+var errNotifyNoSocket = errors.New("No socket")
-// Notify sends a message to the init daemon. It is common to ignore
-// the error.
+// Notify sends a message to the service manager aobout state
+// changes. It is common to ignore the error.
+//
+// If unsetEnv is true, then (regarless of whether the function call
+// itself succeeds or not) it will unset the environmental variable
+// NOTIFY_SOCKET, which will cause further calls to this function to
+// fail.
+//
+// The state parameter should countain a newline-separated list of
+// variable assignments.
+//
+// See the documentation for sd_notify(3) for well-known variable
+// assignments.
func Notify(unsetEnv bool, state string) error {
if unsetEnv {
defer os.Unsetenv("NOTIFY_SOCKET")
@@ -38,7 +49,7 @@ func Notify(unsetEnv bool, state string) error {
}
if socketAddr.Name == "" {
- return ErrNotifyNoSocket
+ return errNotifyNoSocket
}
conn, err := net.DialUnix(socketAddr.Net, nil, socketAddr)