/** @inheritDoc */ public void close(int fd) throws IOException { // NOTE: this would block the VM. A real implementation should // make this a async native method. sockets.shutdown(fd, 2); libc.close(fd); if (DEBUG) { System.out.println("close(" + fd + ")"); } }
/** Read errno, try to clean up fd, and create exception. */ private IOException newError(int fd, String msg) { if (DEBUG) { VM.print(msg); VM.print(": errno: "); } int err_code = LibCUtil.errno(); if (DEBUG) { VM.print(err_code); VM.println(); } sockets.shutdown(fd, 2); libc.close(fd); return new IOException(" errno: " + err_code + " on fd: " + fd + " during " + msg); }