/** * Mimics the POSIX dup2(2) function, returning a new descriptor that references * the same open channel but with a specified fileno. This differs from the fileno * version by making the target descriptor into a new reference to the current * descriptor's channel, closing what it originally pointed to and preserving * its original fileno. * * @param other the descriptor to dup this one into */ public void dup2Into(ChannelDescriptor other) throws BadDescriptorException, IOException { synchronized (refCounter) { refCounter.incrementAndGet(); if (DEBUG) LOG.info("Reopen fileno {}, refs now: {}", internalFileno, refCounter.get()); other.close(); other.channel = channel; other.originalModes = originalModes; other.fileDescriptor = fileDescriptor; other.refCounter = refCounter; other.canBeSeekable = canBeSeekable; other.readableChannel = readableChannel; other.writableChannel = writableChannel; other.seekableChannel = seekableChannel; } }
/** * Mimics the POSIX dup2(2) function, returning a new descriptor that references * the same open channel but with a specified fileno. This differs from the fileno * version by making the target descriptor into a new reference to the current * descriptor's channel, closing what it originally pointed to and preserving * its original fileno. * * @param other the descriptor to dup this one into */ public void dup2Into(ChannelDescriptor other) throws BadDescriptorException, IOException { synchronized (refCounter) { refCounter.incrementAndGet(); if (DEBUG) LOG.info("Reopen fileno {}, refs now: {}", internalFileno, refCounter.get()); other.close(); other.channel = channel; other.originalModes = originalModes; other.fileDescriptor = fileDescriptor; other.refCounter = refCounter; other.canBeSeekable = canBeSeekable; other.readableChannel = readableChannel; other.writableChannel = writableChannel; other.seekableChannel = seekableChannel; } }
/** * Mimics the POSIX dup2(2) function, returning a new descriptor that references * the same open channel but with a specified fileno. This differs from the fileno * version by making the target descriptor into a new reference to the current * descriptor's channel, closing what it originally pointed to and preserving * its original fileno. * * @param other the descriptor to dup this one into */ public void dup2Into(ChannelDescriptor other) throws BadDescriptorException, IOException { synchronized (refCounter) { refCounter.incrementAndGet(); if (DEBUG) LOG.info("Reopen fileno {}, refs now: {}", internalFileno, refCounter.get()); other.close(); other.channel = channel; other.originalModes = originalModes; other.fileDescriptor = fileDescriptor; other.refCounter = refCounter; other.canBeSeekable = canBeSeekable; other.readableChannel = readableChannel; other.writableChannel = writableChannel; other.seekableChannel = seekableChannel; } }
/** * Mimics the POSIX dup2(2) function, returning a new descriptor that references * the same open channel but with a specified fileno. This differs from the fileno * version by making the target descriptor into a new reference to the current * descriptor's channel, closing what it originally pointed to and preserving * its original fileno. * * @param other the descriptor to dup this one into */ public void dup2Into(ChannelDescriptor other) throws BadDescriptorException, IOException { synchronized (refCounter) { refCounter.incrementAndGet(); if (DEBUG) LOG.info("Reopen fileno {}, refs now: {}", internalFileno, refCounter.get()); other.close(); other.channel = channel; other.originalModes = originalModes; other.fileDescriptor = fileDescriptor; other.refCounter = refCounter; other.canBeSeekable = canBeSeekable; other.readableChannel = readableChannel; other.writableChannel = writableChannel; other.seekableChannel = seekableChannel; } }
descriptor.close();
descriptor.close();