mirror of
https://github.com/opencontainers/runc.git
synced 2025-09-27 03:46:19 +08:00
setupIO: close conn on error
While it does not make much sense practically, as runc is going to exit soon and all fds will be closed anyway, various linters (including SVACE) keep reporting this. Let's make them happy. Reported-by: Tigran Sogomonian <tsogomonian@astralinux.ru> Reported-by: Mikhail Dmitrichenko <m.dmitrichenko222@gmail.com> Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
@@ -95,7 +95,7 @@ func newProcess(p *specs.Process) (*libcontainer.Process, error) {
|
||||
}
|
||||
|
||||
// setupIO modifies the given process config according to the options.
|
||||
func setupIO(process *libcontainer.Process, container *libcontainer.Container, createTTY, detach bool, sockpath string) (*tty, error) {
|
||||
func setupIO(process *libcontainer.Process, container *libcontainer.Container, createTTY, detach bool, sockpath string) (_ *tty, Err error) {
|
||||
if createTTY {
|
||||
process.Stdin = nil
|
||||
process.Stdout = nil
|
||||
@@ -121,6 +121,11 @@ func setupIO(process *libcontainer.Process, container *libcontainer.Container, c
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer func() {
|
||||
if Err != nil {
|
||||
conn.Close()
|
||||
}
|
||||
}()
|
||||
t.postStart = append(t.postStart, conn)
|
||||
socket, err := conn.(*net.UnixConn).File()
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user