summaryrefslogtreecommitdiff
path: root/libgo/go/os/exec_posix.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/os/exec_posix.go')
-rw-r--r--libgo/go/os/exec_posix.go19
1 files changed, 15 insertions, 4 deletions
diff --git a/libgo/go/os/exec_posix.go b/libgo/go/os/exec_posix.go
index dbbb5df8c4a..4c8261295c0 100644
--- a/libgo/go/os/exec_posix.go
+++ b/libgo/go/os/exec_posix.go
@@ -10,10 +10,11 @@ import (
"syscall"
)
-// The only signal values guaranteed to be present in the os package
-// on all systems are Interrupt (send the process an interrupt) and
-// Kill (force the process to exit). Interrupt is not implemented on
-// Windows; using it with os.Process.Signal will return an error.
+// The only signal values guaranteed to be present in the os package on all
+// systems are os.Interrupt (send the process an interrupt) and os.Kill (force
+// the process to exit). On Windows, sending os.Interrupt to a process with
+// os.Process.Signal is not implemented; it will return an error instead of
+// sending a signal.
var (
Interrupt Signal = syscall.SIGINT
Kill Signal = syscall.SIGKILL
@@ -106,3 +107,13 @@ func (p *ProcessState) String() string {
}
return res
}
+
+// ExitCode returns the exit code of the exited process, or -1
+// if the process hasn't exited or was terminated by a signal.
+func (p *ProcessState) ExitCode() int {
+ // return -1 if the process hasn't started.
+ if p == nil {
+ return -1
+ }
+ return p.status.ExitStatus()
+}