rclone/vendor/github.com/okzk/sdnotify/notify_linux.go
2017-11-20 11:03:10 +00:00

22 lines
354 B
Go

package sdnotify
import (
"net"
"os"
)
func SdNotify(state string) error {
name := os.Getenv("NOTIFY_SOCKET")
if name == "" {
return SdNotifyNoSocket
}
conn, err := net.DialUnix("unixgram", nil, &net.UnixAddr{Name: name, Net: "unixgram"})
if err != nil {
return err
}
defer conn.Close()
_, err = conn.Write([]byte(state))
return err
}