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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ module github.com/jstarks/npiperelay

go 1.13

require golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae
require golang.org/x/sys v0.5.0
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae h1:Ih9Yo4hSPImZOpfGuA4bR/ORKTAbhZo2AbWNRCnevdo=
golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
8 changes: 7 additions & 1 deletion npiperelay.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
const cERROR_PIPE_NOT_CONNECTED syscall.Errno = 233

var (
poll = flag.Bool("p", false, "poll until the the named pipe exists")
poll = flag.Bool("p", true, "poll until the the named pipe exists")
closeWrite = flag.Bool("s", false, "send a 0-byte message to the pipe after EOF on stdin")
closeOnEOF = flag.Bool("ep", false, "terminate on EOF reading from the pipe, even if there is more data to write")
closeOnStdinEOF = flag.Bool("ei", false, "terminate on EOF reading from stdin, even if there is more data to write")
Expand All @@ -27,6 +27,7 @@ func dialPipe(p string, poll bool) (*overlappedFile, error) {
if err != nil {
return nil, err
}
var errCount int
for {
h, err := windows.CreateFile(&p16[0], windows.GENERIC_READ|windows.GENERIC_WRITE, 0, nil, windows.OPEN_EXISTING, windows.FILE_FLAG_OVERLAPPED, 0)
if err == nil {
Expand All @@ -36,6 +37,11 @@ func dialPipe(p string, poll bool) (*overlappedFile, error) {
time.Sleep(200 * time.Millisecond)
continue
}
if err != nil && errCount < 200 {
time.Sleep(200 * time.Millisecond)
errCount++
continue
}
return nil, &os.PathError{Path: p, Op: "open", Err: err}
}
}
Expand Down