From f719baa08af03470ef9575f2eb916dd2025eeb36 Mon Sep 17 00:00:00 2001 From: wpelissero Date: Tue, 8 Dec 2015 17:23:06 +0100 Subject: [PATCH 1/2] Keep sending signals even if input ends --- io.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/io.go b/io.go index b96a466..68c1eff 100644 --- a/io.go +++ b/io.go @@ -86,7 +86,8 @@ func inLoop2(pipe io.WriteCloser, proc *exec.Cmd, stdin io.Reader, done chan boo logger.Printf("in: packet length = %v\n", length) if length == 0 { // this is how Porcelain signals EOF from Elixir - break + pipe.Close() + continue } _, read_err = io.ReadFull(stdin, buf[2:]) @@ -122,6 +123,7 @@ func inLoop2(pipe io.WriteCloser, proc *exec.Cmd, stdin io.Reader, done chan boo } } pipe.Close() + logger.Println("Exiting stdin loop") done <- true } From ef18a476fda99a02f79d80efd8cf5e1f6b7a6e48 Mon Sep 17 00:00:00 2001 From: wpelissero Date: Tue, 8 Dec 2015 17:48:49 +0100 Subject: [PATCH 2/2] Always start the inLoop2() Otherwise we can't send signals to the controlled process. --- io.go | 2 -- proto_2_0.go | 5 +---- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/io.go b/io.go index 68c1eff..15e924a 100644 --- a/io.go +++ b/io.go @@ -74,7 +74,6 @@ func inLoop(pipe io.WriteCloser, stdin io.Reader, done chan bool) { func inLoop2(pipe io.WriteCloser, proc *exec.Cmd, stdin io.Reader, done chan bool) { buf := make([]byte, 3) logger.Println("Entering stdin loop") - done <- true loop: for { bytes_read, read_err := io.ReadFull(stdin, buf[:2]) if read_err == io.EOF && bytes_read == 0 { @@ -124,7 +123,6 @@ func inLoop2(pipe io.WriteCloser, proc *exec.Cmd, stdin io.Reader, done chan boo } pipe.Close() logger.Println("Exiting stdin loop") - done <- true } /// diff --git a/proto_2_0.go b/proto_2_0.go index 37b9f79..89b82b1 100644 --- a/proto_2_0.go +++ b/proto_2_0.go @@ -19,10 +19,7 @@ func proto_2_0(inFlag, outFlag bool, errFlag, workdir string, args []string) err doneChan := make(chan bool, 3) doneCount := 0 - if inFlag { - wrapStdin2(proc, os.Stdin, doneChan) - doneCount++ - } + wrapStdin2(proc, os.Stdin, doneChan) if outFlag { wrapStdout(proc, os.Stdout, stdoutMarker, doneChan)