From 1362291a6d53a8575a236114c5b9d59fd3907cb8 Mon Sep 17 00:00:00 2001 From: Dave Chen Date: Thu, 18 Nov 2021 10:48:58 +0800 Subject: [PATCH] Avoid non-op when the list of `Hooks` is empty There is no need to run hooks when `Config.Hooks` is just an empty map, (dlv) p p.config.Config.Hooks github.com/opencontainers/runc/libcontainer/configs.Hooks [] Signed-off-by: Dave Chen --- libcontainer/process_linux.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libcontainer/process_linux.go b/libcontainer/process_linux.go index 3913e3855d8..e025445d330 100644 --- a/libcontainer/process_linux.go +++ b/libcontainer/process_linux.go @@ -516,7 +516,7 @@ func (p *initProcess) start() (retErr error) { } } - if p.config.Config.Hooks != nil { + if len(p.config.Config.Hooks) != 0 { s, err := p.container.currentOCIState() if err != nil { return err @@ -571,7 +571,7 @@ func (p *initProcess) start() (retErr error) { return fmt.Errorf("error setting Intel RDT config for procHooks process: %w", err) } } - if p.config.Config.Hooks != nil { + if len(p.config.Config.Hooks) != 0 { s, err := p.container.currentOCIState() if err != nil { return err