pkg/term

Unable to obtain underlying error causing short write.

max-okumoto opened this issue · 1 comments

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
}

I'm sorry, there's nothing this package can do, the operating system doesn't give an explanation why the write didn't complete, Sorry.