Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions c/seg.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ int main(int argc, char* argv[])
setvbuf(stdout, NULL, _IOLBF, 0);
setvbuf(stderr, NULL, _IOLBF, 0);

char buffer[100];
fgets(buffer, 100, stdin);
printf("From stdin: %s\n", buffer);

printf("C test\n");
sleep(1);
printf("1\n");
Expand Down
25 changes: 9 additions & 16 deletions gocmd/gocmd.go
Original file line number Diff line number Diff line change
@@ -1,30 +1,23 @@
package main

import (
"bytes"
"fmt"
"io"
"time"

"github.com/go-cmd/cmd"
)

//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 main() {
testCmd := cmd.NewCmd("../c/seg")
rt := NewTestReader()
statusChan := testCmd.StartWithStdin(rt)
reader, writer := io.Pipe()
go func() {
_, _ = io.Copy(writer, bytes.NewBufferString("hello from the other side\n"))
// close immediately
_ = writer.Close()
}()
statusChan := testCmd.StartWithStdin(reader)

ticker := time.NewTicker(1 * time.Second)

Expand Down