Skip to content

Commit 3768ffe

Browse files
authored
Merge pull request #17 from liny01-nbsa/patch-1
Update repeater.go, fix for #16
2 parents b82a602 + 465c8ed commit 3768ffe

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

repeater.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,19 @@ func newRepeater(ctx context.Context, powershell string, pipename string) (*repe
6060
// wait for the process start up
6161
go func() {
6262
// the process should output "\xff" if it starts successfully
63+
// ignore any output until we got "\xff"
6364
buf := make([]byte, 1)
64-
n, err := out.Read(buf)
65-
done <- err == nil && n == 1 && buf[0] == 0xff
65+
for {
66+
n, err := out.Read(buf)
67+
if err != nil {
68+
done <- false
69+
return
70+
}
71+
if n == 1 && buf[0] == 0xff {
72+
done <- true
73+
return
74+
}
75+
}
6676
}()
6777

6878
select {

repeater_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ $stdin.read
1616

1717
const dummyEchoPowerShell = `#!/usr/bin/ruby
1818
$stdout.sync = true
19+
$stdout << "Warning: Some dummy ramdom warming messages ... Dummy ...\n"
1920
$stdout << "\xff"
2021
loop do
2122
$stdout << $stdin.getc

0 commit comments

Comments
 (0)