summaryrefslogtreecommitdiff
path: root/src/pkg/os/exec_unix.go
diff options
context:
space:
mode:
authorOndřej Surý <ondrej@sury.org>2012-01-30 15:38:19 +0100
committerOndřej Surý <ondrej@sury.org>2012-01-30 15:38:19 +0100
commit4cecda6c347bd6902b960c6a35a967add7070b0d (patch)
treea462e224ff41ec9f3eb1a0b6e815806f9e8804ad /src/pkg/os/exec_unix.go
parent6c7ca6e4d4e26e4c8cbe0d183966011b3b088a0a (diff)
downloadgolang-4cecda6c347bd6902b960c6a35a967add7070b0d.tar.gz
Imported Upstream version 2012.01.27upstream-weekly/2012.01.27
Diffstat (limited to 'src/pkg/os/exec_unix.go')
-rw-r--r--src/pkg/os/exec_unix.go24
1 files changed, 11 insertions, 13 deletions
diff --git a/src/pkg/os/exec_unix.go b/src/pkg/os/exec_unix.go
index e1adb203e..6c11b63c3 100644
--- a/src/pkg/os/exec_unix.go
+++ b/src/pkg/os/exec_unix.go
@@ -2,11 +2,12 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build darwin freebsd linux openbsd
+// +build darwin freebsd linux netbsd openbsd
package os
import (
+ "errors"
"runtime"
"syscall"
)
@@ -24,9 +25,9 @@ const (
// the options
// Wait waits for the Process to exit or stop, and then returns a
-// Waitmsg describing its status and an Error, if any. The options
+// Waitmsg describing its status and an error, if any. The options
// (WNOHANG etc.) affect the behavior of the Wait call.
-func (p *Process) Wait(options int) (w *Waitmsg, err Error) {
+func (p *Process) Wait(options int) (w *Waitmsg, err error) {
if p.Pid == -1 {
return nil, EINVAL
}
@@ -37,7 +38,7 @@ func (p *Process) Wait(options int) (w *Waitmsg, err Error) {
options ^= WRUSAGE
}
pid1, e := syscall.Wait4(p.Pid, &status, options, rusage)
- if e != 0 {
+ if e != nil {
return nil, NewSyscallError("wait", e)
}
// With WNOHANG pid is 0 if child has not exited.
@@ -52,18 +53,18 @@ func (p *Process) Wait(options int) (w *Waitmsg, err Error) {
}
// Signal sends a signal to the Process.
-func (p *Process) Signal(sig Signal) Error {
+func (p *Process) Signal(sig Signal) error {
if p.done {
- return NewError("os: process already finished")
+ return errors.New("os: process already finished")
}
- if e := syscall.Kill(p.Pid, int(sig.(UnixSignal))); e != 0 {
- return Errno(e)
+ if e := syscall.Kill(p.Pid, int(sig.(UnixSignal))); e != nil {
+ return e
}
return nil
}
// Release releases any resources associated with the Process.
-func (p *Process) Release() Error {
+func (p *Process) Release() error {
// NOOP for unix.
p.Pid = -1
// no need for a finalizer anymore
@@ -71,10 +72,7 @@ func (p *Process) Release() Error {
return nil
}
-// FindProcess looks for a running process by its pid.
-// The Process it returns can be used to obtain information
-// about the underlying operating system process.
-func FindProcess(pid int) (p *Process, err Error) {
+func findProcess(pid int) (p *Process, err error) {
// NOOP for unix.
return newProcess(pid, 0), nil
}