mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
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:
+3
-4
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user