From 09f126691c8304510b9028fc1f564163e714b2ea Mon Sep 17 00:00:00 2001 From: Madhu Rajanna Date: Wed, 3 Jul 2019 09:23:11 +0530 Subject: [PATCH] Add nil check for process Signed-off-by: Madhu Rajanna --- pkg/cephfs/util.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/cephfs/util.go b/pkg/cephfs/util.go index 573cedb39..52d9c9bb5 100644 --- a/pkg/cephfs/util.go +++ b/pkg/cephfs/util.go @@ -49,6 +49,10 @@ func execCommand(program string, args ...string) (stdout, stderr []byte, err err klog.V(4).Infof("cephfs: EXEC %s %s", program, sanitizedArgs) if err := cmd.Run(); err != nil { + if cmd.Process == nil { + return nil, nil, fmt.Errorf("cannot get process pid while running %s %v: %v: %s", + program, sanitizedArgs, err, stderrBuf.Bytes()) + } return nil, nil, fmt.Errorf("an error occurred while running (%d) %s %v: %v: %s", cmd.Process.Pid, program, sanitizedArgs, err, stderrBuf.Bytes()) }