summaryrefslogtreecommitdiff
path: root/shell.go
diff options
context:
space:
mode:
Diffstat (limited to 'shell.go')
-rw-r--r--shell.go56
1 files changed, 0 insertions, 56 deletions
diff --git a/shell.go b/shell.go
index 21982af..4f0abf5 100644
--- a/shell.go
+++ b/shell.go
@@ -1,14 +1,12 @@
package shell
import (
- "bufio"
"io/ioutil"
"os"
"os/exec"
"strings"
"time"
- "github.com/svent/go-nbreader"
"go.wit.com/log"
)
@@ -85,21 +83,6 @@ func RM(filename string) {
os.Remove(Path(filename))
}
-/*
- err := process.Wait()
-
- if err != nil {
- if (spewOn) {
- // this panics: spew.Dump(err.(*exec.ExitError))
- spew.Dump(process.ProcessState)
- }
- // stuff := err.(*exec.ExitError)
- log.Log(INFO, "ERROR ", err.Error())
- log.Log(INFO, "END ", cmdline)
- handleError(err, -1)
- return ""
-*/
-
func Daemon(cmdline string, timeout time.Duration) int {
for {
RunString(cmdline)
@@ -107,45 +90,6 @@ func Daemon(cmdline string, timeout time.Duration) int {
}
}
-// pass in two file handles (1 read, 1 write)
-func nonBlockingReader(buffReader *bufio.Reader, writeFileHandle *os.File, stdout *bufio.Writer) {
- // newreader := bufio.NewReader(readFileHandle)
-
- // create a nonblocking GO reader
- nbr := nbreader.NewNBReader(buffReader, 1024)
-
- for {
- // defer buffReader.Close()
- // defer writeFileHandle.Flush()
- defer writeFileHandle.Close()
- totalCount := 0
- for {
- oneByte := make([]byte, 1024)
- count, err := nbr.Read(oneByte)
- if err != nil {
- log.Log(INFO, "count, err =", count, err)
- handleError(err, -1)
- return
- }
- totalCount += count
- if count == 0 {
- time.Sleep(time.Duration(msecDelay) * time.Millisecond) // without this delay this will peg the CPU
- if totalCount != 0 {
- log.Log(INFO, "STDERR: totalCount = ", totalCount)
- totalCount = 0
- }
- } else {
- log.Log(INFO, "STDERR: count = ", count)
- writeFileHandle.Write(oneByte[0:count])
- if quiet == false {
- stdout.Write(oneByte[0:count])
- stdout.Flush()
- }
- }
- }
- }
-}
-
// run something and never return from it
// TODO: pass STDOUT, STDERR, STDIN correctly
// TODO: figure out how to nohup the process and exit