stoop it.

This commit is contained in:
Andrey Parhomenko 2023-06-04 22:10:30 +03:00
parent 5dc0759533
commit ccc9c1a578

View file

@ -78,7 +78,7 @@ func setupEnv() {
panic("too few arguments") panic("too few arguments")
} }
cmd := exec.Command(args[0], args...) cmd := exec.Command(args[0], args[1:]...)
return &Cmd{ return &Cmd{
Cmd: cmd, Cmd: cmd,
@ -111,25 +111,32 @@ func setupEnv() {
ibuf := make([]byte, 512) ibuf := make([]byte, 512)
obuf := make([]byte, 512) obuf := make([]byte, 512)
for {
fmt.Println("in")
ni, err := input.Read(ibuf)
stdin.Write(ibuf[:ni])
if err == io.EOF {
break
} else if err != nil {
fmt.Println("check")
panic(err)
}
no, err := stdout.Read(obuf) go func() {
output.Write(obuf[:no]) for {
if err == io.EOF { no, err := stdout.Read(obuf)
break output.Write(obuf[:no])
} else if err != nil { if err == io.EOF {
panic(err) break
} else if err != nil {
panic(err)
}
} }
} stdout.Close()
}()
go func() {
for {
ni, err := input.Read(ibuf)
stdin.Write(ibuf[:ni])
if err == io.EOF {
break
} else if err != nil {
panic(err)
}
}
stdin.Close()
}()
err = rcmd.Wait() err = rcmd.Wait()
if err != nil { if err != nil {