Do not return -1 from Read() and Write()

Closes #55
This commit is contained in:
Andrey Demenev
2019-02-03 03:35:32 +10:00
committed by Cristian Maglie
parent f7a06a7c47
commit 1131ba52fd

View File

@@ -74,12 +74,19 @@ func (port *unixPort) Read(p []byte) (int, error) {
if err == unix.EINTR { if err == unix.EINTR {
continue continue
} }
if n < 0 { // Do not return -1 unix errors
n = 0
}
return n, err return n, err
} }
} }
func (port *unixPort) Write(p []byte) (n int, err error) { func (port *unixPort) Write(p []byte) (n int, err error) {
return unix.Write(port.handle, p) n, err = unix.Write(port.handle, p)
if n < 0 { // Do not return -1 unix errors
n = 0
}
return
} }
func (port *unixPort) ResetInputBuffer() error { func (port *unixPort) ResetInputBuffer() error {