@Override
	public synchronized int read(byte[] b, int off, int len) throws IOException {
		if (closed) {
			throw new IOException("Stream closed");
		}
		if (len == 0) {
			return 0;
		}
		Memory buf = new Memory(len);
		int ret;
		try {
			ret = LIB_POSIX.read(fd, buf, len);
		}
		catch (LastErrorException e) {
			if (e.getErrorCode() == 5 || e.getErrorCode() == 9) {
				throw new IOException(e);
			}
			throw e;
		}
		buf.read(0, b, off, ret);
		return ret;
	}
Wrap the given file descriptor in an {@link InputStream}

@param fd the file descriptor
Ghidra/Framework/Pty/src/main/java/ghidra/pty/unix/FdInputStream.java