aboutsummaryrefslogtreecommitdiffstats
path: root/sandbox-go
diff options
context:
space:
mode:
Diffstat (limited to 'sandbox-go')
-rw-r--r--sandbox-go/src/main.go6
-rw-r--r--sandbox-go/src/parent.go8
2 files changed, 6 insertions, 8 deletions
diff --git a/sandbox-go/src/main.go b/sandbox-go/src/main.go
index a881e3a..0a40368 100644
--- a/sandbox-go/src/main.go
+++ b/sandbox-go/src/main.go
@@ -54,7 +54,7 @@ func cleanup() {
}
func main() {
- runtime.GOMAXPROCS(3)
+ runtime.GOMAXPROCS(8)
dec := json.NewDecoder(os.Stdin)
var plan plan
if err := dec.Decode(&plan); err != nil {
@@ -85,10 +85,10 @@ func main() {
if err := syscall.Pipe2(stdin_fd[:], 0); err != nil {
poePanic(err, "pipe2 failed")
}
- if err := syscall.Pipe2(stdout_fd[:], syscall.O_DIRECT|syscall.O_NONBLOCK); err != nil {
+ if err := syscall.Pipe2(stdout_fd[:], syscall.O_DIRECT); err != nil {
poePanic(err, "pipe2 failed")
}
- if err := syscall.Pipe2(stderr_fd[:], syscall.O_DIRECT|syscall.O_NONBLOCK); err != nil {
+ if err := syscall.Pipe2(stderr_fd[:], syscall.O_DIRECT); err != nil {
poePanic(err, "pipe2 failed")
}
diff --git a/sandbox-go/src/parent.go b/sandbox-go/src/parent.go
index 35a2df2..5fbbf28 100644
--- a/sandbox-go/src/parent.go
+++ b/sandbox-go/src/parent.go
@@ -3,7 +3,6 @@ package main
import (
"bytes"
"encoding/binary"
- "unsafe"
"fmt"
"os"
"os/signal"
@@ -82,12 +81,11 @@ func doParent(mpid int, stdin_fd, stdout_fd, stderr_fd [2]int) resultPack {
var buf [65536]byte // TODO: how to get PIPE_BUF?
for ev := 0; ev < en; ev++ {
for {
- r1, _, e1 := syscall.Syscall(syscall.SYS_READ, uintptr(events[ev].Fd), uintptr(unsafe.Pointer(&buf[0])), uintptr(len(buf)))
- if e1 != 0 {
+ n, err := syscall.Read(int(events[ev].Fd), buf[:])
+ if err != nil {
break
}
- n := int(r1)
- if r1 > 0 {
+ if n > 0 {
nbuf := make([]byte, n)
copy(nbuf, buf[:n])
out_chan <- childOutput{int(events[ev].Pad), n, nbuf}