initial commit

This commit is contained in:
ston1th 2019-04-19 15:45:28 +02:00
commit 18995db757
871 changed files with 492725 additions and 0 deletions

31
pkg/core/timeout.go Normal file
View file

@ -0,0 +1,31 @@
package core
import (
"os/exec"
"time"
)
func Timeout(cmd *exec.Cmd, t time.Duration) (output []byte, err error) {
done := make(chan error)
out := make(chan []byte)
go func() {
o, e := cmd.Output()
done <- e
out <- o
}()
select {
case <-time.After(t):
e := cmd.Process.Kill()
<-out
if e != nil {
<-done
err = e
return
}
err = <-done
case e := <-done:
err = e
output = <-out
}
return
}