From 42ece23fee2015a421e3456598ceef45dfc74f5f Mon Sep 17 00:00:00 2001 From: Roger Riggs Date: Mon, 13 Dec 2021 14:23:07 -0500 Subject: [PATCH] 8276651: java/lang/ProcessHandle/InfoTest.java failed with "RuntimeException: Input/output error" If the pid is invalid, errno == EIO(5), the information returned is empty and no exception is thrown --- .../macosx/native/libjava/ProcessHandleImpl_macosx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/java.base/macosx/native/libjava/ProcessHandleImpl_macosx.c b/src/java.base/macosx/native/libjava/ProcessHandleImpl_macosx.c index dfe40f54a68c4..8987f0b97a4da 100644 --- a/src/java.base/macosx/native/libjava/ProcessHandleImpl_macosx.c +++ b/src/java.base/macosx/native/libjava/ProcessHandleImpl_macosx.c @@ -272,7 +272,8 @@ void os_getCmdlineAndUserInfo(JNIEnv *env, jobject jinfo, pid_t pid) { mib[2] = pid; size = (size_t) maxargs; if (sysctl(mib, 3, args, &size, NULL, 0) == -1) { - if (errno != EINVAL) { + if (errno != EINVAL && errno != EIO) { + // If the pid is invalid, the information returned is empty and no exception JNU_ThrowByNameWithLastError(env, "java/lang/RuntimeException", "sysctl failed"); } @@ -300,4 +301,3 @@ void os_getCmdlineAndUserInfo(JNIEnv *env, jobject jinfo, pid_t pid) { // Free the arg buffer free(args); } -