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,17 +111,9 @@ 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)
}
go func() {
for {
no, err := stdout.Read(obuf) no, err := stdout.Read(obuf)
output.Write(obuf[:no]) output.Write(obuf[:no])
if err == io.EOF { if err == io.EOF {
@ -130,6 +122,21 @@ func setupEnv() {
panic(err) 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 {