MCPcopy Index your code
hub / github.com/foxcpp/maddy / systemdStatusErr

Function systemdStatusErr

systemd.go:110–141  ·  view source on GitHub ↗
(reportedErr error)

Source from the content-addressed store, hash-verified

108}
109
110func systemdStatusErr(reportedErr error) {
111 sock, err := sdNotifySock()
112 if err != nil {
113 if !errors.Is(err, ErrNoNotifySock) {
114 log.Println("systemd: failed to acquire notify socket:", err)
115 }
116 return
117 }
118 defer func() {
119 if err := sock.Close(); err != nil {
120 log.Println("systemd: failed to close systemd socket:", err)
121 }
122 }()
123
124 if err := setScmPassCred(sock); err != nil {
125 log.Println("systemd: failed to set SCM_PASSCRED on the socket:", err)
126 }
127
128 var errno syscall.Errno
129 if errors.As(reportedErr, &errno) {
130 log.Debugf(`systemd: ERRNO=%d STATUS="%v"`, errno, reportedErr)
131 if _, err := io.WriteString(sock, fmt.Sprintf("ERRNO=%d\nSTATUS=%v", errno, reportedErr)); err != nil {
132 log.Println("systemd: I/O error:", err)
133 }
134 return
135 }
136
137 if _, err := io.WriteString(sock, fmt.Sprintf("STATUS=%v\n", reportedErr)); err != nil {
138 log.Println("systemd: I/O error:", err)
139 }
140 log.Debugf(`systemd: STATUS="%v"`, reportedErr)
141}

Callers 1

RunFunction · 0.70

Calls 5

PrintlnFunction · 0.92
DebugfFunction · 0.92
sdNotifySockFunction · 0.85
setScmPassCredFunction · 0.85
CloseMethod · 0.65

Tested by

no test coverage detected