From 298cd1b285641256c14f4e83ffbc0bb2201cde03 Mon Sep 17 00:00:00 2001 From: rajasec Date: Wed, 20 Jan 2016 22:46:12 +0530 Subject: [PATCH] Added error string for process operations Signed-off-by: rajasec Changing the error code string name as per review comments Signed-off-by: rajasec --- libcontainer/error.go | 4 +++- libcontainer/process.go | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/libcontainer/error.go b/libcontainer/error.go index 378ef469..b50aaae8 100644 --- a/libcontainer/error.go +++ b/libcontainer/error.go @@ -19,7 +19,7 @@ const ( ContainerNotPaused // Process errors - ProcessNotExecuted + NoProcessOps // Common errors ConfigInvalid @@ -49,6 +49,8 @@ func (c ErrorCode) String() string { return "Console exists for process" case ContainerNotPaused: return "Container is not paused" + case NoProcessOps: + return "No process operations" default: return "Unknown error" } diff --git a/libcontainer/process.go b/libcontainer/process.go index 9661df80..8b4c558b 100644 --- a/libcontainer/process.go +++ b/libcontainer/process.go @@ -55,7 +55,7 @@ type Process struct { // Wait releases any resources associated with the Process func (p Process) Wait() (*os.ProcessState, error) { if p.ops == nil { - return nil, newGenericError(fmt.Errorf("invalid process"), ProcessNotExecuted) + return nil, newGenericError(fmt.Errorf("invalid process"), NoProcessOps) } return p.ops.wait() } @@ -65,7 +65,7 @@ func (p Process) Pid() (int, error) { // math.MinInt32 is returned here, because it's invalid value // for the kill() system call. if p.ops == nil { - return math.MinInt32, newGenericError(fmt.Errorf("invalid process"), ProcessNotExecuted) + return math.MinInt32, newGenericError(fmt.Errorf("invalid process"), NoProcessOps) } return p.ops.pid(), nil } @@ -73,7 +73,7 @@ func (p Process) Pid() (int, error) { // Signal sends a signal to the Process. func (p Process) Signal(sig os.Signal) error { if p.ops == nil { - return newGenericError(fmt.Errorf("invalid process"), ProcessNotExecuted) + return newGenericError(fmt.Errorf("invalid process"), NoProcessOps) } return p.ops.signal(sig) }