Skip to content
Closed
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
8 changes: 8 additions & 0 deletions serial_posix.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ func (p *port) Read(b []byte) (n int, err error) {
return
}
n, err = syscall.Read(fd, b)
if n < 0 {
// underlying syscall.Read returns -1 on error, but we want to return 0 to be consistent with io.Reader interface.
if err == nil {
// This should not happen, but just in case.
err = fmt.Errorf("serial: read returned %v without error", n)
}
n = 0
}
return
}

Expand Down