fix a ambiguity of err in defer func

We should use a named return value of error, or else we can't
catch all errors when calling defer function, for example we
used a block scope var name `err` for `setupPidfdSocket`.

Signed-off-by: lifubang <lifubang@acmcoder.com>
This commit is contained in:
lifubang
2025-03-19 10:50:33 +00:00
committed by Kir Kolyshkin
parent 348d92f497
commit 456d0f525a
+3 -4
View File
@@ -219,14 +219,13 @@ type runner struct {
subCgroupPaths map[string]string
}
func (r *runner) run(config *specs.Process) (int, error) {
var err error
func (r *runner) run(config *specs.Process) (_ int, retErr error) {
defer func() {
if err != nil {
if retErr != nil {
r.destroy()
}
}()
if err = r.checkTerminal(config); err != nil {
if err := r.checkTerminal(config); err != nil {
return -1, err
}
process, err := newProcess(config)