Open
Description
Thanks for maintaining go-cmd.
I've got a C program that get's started with stdin
.
This allows the Go code to send instructions over stdin
to the C program.
However if the C program finishes, the cmd.Status
chan does not seem to unblock.
Is there something I'm doing wrong here?
Go code:
//Dummy reader which does nothing
type TestReader struct {
}
//Read get's called by go-cmd
func (rt *TestReader) Read(p []byte) (n int, err error) {
return 0, nil
}
func NewTestReader() *TestReader {
rt := TestReader{}
return &rt
}
func buffered() {
testCmd := cmd.NewCmd("seg")
rt := NewTestReader()
statusChan := testCmd.StartWithStdin(rt)
// statusChan := testCmd.Start()
ticker := time.NewTicker(1 * time.Second)
go func() {
for range ticker.C {
status := testCmd.Status()
fmt.Println(status.Stdout)
fmt.Println(status.Stderr)
}
}()
// Block waiting for command to exit, be stopped, or be killed.
// This does not unblock
state := <-statusChan
fmt.Println("statusChan final state")
fmt.Println(state.Stdout)
fmt.Println(state.Stderr)
}
C code:
#include <unistd.h>
int main(int argc, char* argv[])
{
setvbuf(stdout, NULL, _IOLBF, 0);
setvbuf(stderr, NULL, _IOLBF, 0);
printf("C test\n");
sleep(1);
printf("1\n");
sleep(1);
printf("done\n");
}```
Metadata
Metadata
Assignees
Labels
No labels