Unable to obtain underlying error causing short write. If the syscall.Write() fails due to an error, the code examines the returned length which is very likely to be less than what was intended to be written and returns io.ErShortWrite.
In my case, the USB serial device was removed and I need to know that the fd is bad, so I can take the appropriate action.
func (t *Term) Write(b []byte) (int, error) {
n, e := syscall.Write(t.fd, b)
if n < 0 {
n = 0
}
if n != len(b) {
return n, io.ErrShortWrite
}
if e != nil {
return n, &os.PathError{"write", t.name, e}
}
return n, nil
}
Unable to obtain underlying error causing short write. If the syscall.Write() fails due to an error, the code examines the returned length which is very likely to be less than what was intended to be written and returns io.ErShortWrite.
In my case, the USB serial device was removed and I need to know that the fd is bad, so I can take the appropriate action.
func (t *Term) Write(b []byte) (int, error) { n, e := syscall.Write(t.fd, b) if n < 0 { n = 0 } if n != len(b) { return n, io.ErrShortWrite } if e != nil { return n, &os.PathError{"write", t.name, e} } return n, nil }