From bbc3c5de657746bdbe3ad80b359a98f8a0d00424 Mon Sep 17 00:00:00 2001 From: "Shruthi.Shruthi1" Date: Wed, 4 Jan 2023 22:12:08 -0800 Subject: [PATCH] Hang in PreClose method during dup2 system call During fcntl, dup2 system calls if read/write happens then PreClose method gets hang. This issue is not seen if we Signal/Kill the thread first and then call the preClose method. Signed-off-by: Shruthi.Shruthi1 --- .../unix/classes/sun/nio/ch/SourceChannelImpl.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/java.base/unix/classes/sun/nio/ch/SourceChannelImpl.java b/src/java.base/unix/classes/sun/nio/ch/SourceChannelImpl.java index 99e934e3436..9419ce7bf68 100644 --- a/src/java.base/unix/classes/sun/nio/ch/SourceChannelImpl.java +++ b/src/java.base/unix/classes/sun/nio/ch/SourceChannelImpl.java @@ -23,6 +23,11 @@ * questions. */ +/* + * =========================================================================== + * (c) Copyright IBM Corp. 2022, 2022 All Rights Reserved + * =========================================================================== + */ package sun.nio.ch; import java.io.FileDescriptor; @@ -107,8 +112,8 @@ protected void implCloseSelectableChannel() throws IOException { assert state == ST_CLOSING; long th = thread; if (th != 0) { - nd.preClose(fd); NativeThread.signal(th); + nd.preClose(fd); // wait for read operation to end while (thread != 0) {