ReadOutput for process, and --wait will read process output

This commit is contained in:
Jae Kwon
2015-04-17 10:27:17 -07:00
parent 02bc535e0e
commit 75697034bd
4 changed files with 22 additions and 1 deletions

View File

@ -4,6 +4,7 @@ import (
"bytes"
"fmt"
"io"
"io/ioutil"
"os"
"os/exec"
"time"
@ -83,6 +84,14 @@ func Create(mode int, label string, execPath string, args []string, input string
return proc, nil
}
func ReadOutput(proc *Process) string {
output, err := ioutil.ReadFile(proc.OutputPath)
if err != nil {
return fmt.Sprintf("ERROR READING OUTPUT: %v", err)
}
return string(output)
}
func Stop(proc *Process, kill bool) error {
defer proc.OutputFile.Close()
if kill {