mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-10 21:53:57 +08:00
[1.4] notify_socket: close fds on error
Reported in issue 5008.
Reported-by: Arina Cherednik <arinacherednik034@gmail.com>
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit 93792e6c13)
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
This commit is contained in:
committed by
Aleksa Sarai
parent
d934c6dd9e
commit
5dac7379e7
+7
-1
@@ -175,12 +175,18 @@ func notifyHost(client *net.UnixConn, ready []byte, pid1 int) error {
|
||||
var errUnexpectedRead = errors.New("unexpected read from synchronization pipe")
|
||||
|
||||
// sdNotifyBarrier performs synchronization with systemd by means of the sd_notify_barrier protocol.
|
||||
func sdNotifyBarrier(client *net.UnixConn) error {
|
||||
func sdNotifyBarrier(client *net.UnixConn) (retErr error) {
|
||||
// Create a pipe for communicating with systemd daemon.
|
||||
pipeR, pipeW, err := os.Pipe()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer func() {
|
||||
if retErr != nil {
|
||||
pipeW.Close()
|
||||
pipeR.Close()
|
||||
}
|
||||
}()
|
||||
|
||||
// Get the FD for the unix socket file to be able to use sendmsg.
|
||||
clientFd, err := client.File()
|
||||
|
||||
Reference in New Issue
Block a user