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

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