diff options
author | root <root@krebs> | 2011-09-14 20:36:50 +0200 |
---|---|---|
committer | root <root@krebs> | 2011-09-14 20:36:50 +0200 |
commit | 04af55a06ba25e669a705b3c32a16e91fac05125 (patch) | |
tree | 5ac1d5ccb62a18b4a056872b9864abd5ba92f83b /hyper | |
parent | a8ab9dbc2de0ee3aa744485255360b5e5e8b45cd (diff) | |
parent | e087646763cefc3dae49530fba866aa2bb713f46 (diff) |
Merge branch 'master' of github.com:krebscode/painload
Diffstat (limited to 'hyper')
-rw-r--r-- | hyper/process/Makefile | 14 | ||||
-rw-r--r-- | hyper/process/main.go | 52 |
2 files changed, 66 insertions, 0 deletions
diff --git a/hyper/process/Makefile b/hyper/process/Makefile new file mode 100644 index 00000000..7d61b28d --- /dev/null +++ b/hyper/process/Makefile @@ -0,0 +1,14 @@ + +A := 8 + +.PHONY: all clean +all: main + +clean: + rm -f main *.$A + +%.$A: %.go + $Ag $< + +%: %.$A + $Al -o $@ $< diff --git a/hyper/process/main.go b/hyper/process/main.go new file mode 100644 index 00000000..297be2cf --- /dev/null +++ b/hyper/process/main.go @@ -0,0 +1,52 @@ +package main + +import "fmt" +import "os" + + +func reader(file *os.File) { + var b []byte = make([]byte, 1024) + var err os.Error = nil + for err == nil { + var n int + n, err = file.Read(b) + fmt.Printf("data: %d, %s\n", n, b) + } +} + +func main() { + var name = "/usr/bin/bc" + var argv = []string{ "bc" } + var envv = []string{ "FOO=23" } + //var chroot = false + var dir = "/var/empty" + var files [3][2]*os.File + var err os.Error + + for i, _ := range files { + files[i][0], files[i][1], err = os.Pipe() + err = err + } + + var attr = &os.ProcAttr{ + Dir: dir, + Env: envv, + Files: []*os.File{ /*files[0][0] */ os.Stdin, files[1][1], files[2][1]}, + } + + var p *os.Process + + p, err = os.StartProcess(name, argv, attr) + + for _, file := range attr.Files { + file.Close() + } + + p=p + + go reader(files[1][0]) + reader(files[2][0]) + + fmt.Printf("hello, world\n") + +} |