From f9569f4ea36a5385043e51605df094823c2c3a0a Mon Sep 17 00:00:00 2001 From: Elif Aslan Date: Fri, 8 Mar 2024 22:09:18 +0000 Subject: [PATCH] [PATCH] 8325567: jspawnhelper without args fails with segfault Origin: commit,262747094670b00ac63463a059074afa9b81d8a4 Bug: https://bugs.openjdk.org/browse/JDK-8325567 Co-authored-by: Vladimir Petko Reviewed-by: eastigeevich, rriggs, shade, vpetko Reviewed-by: eastigeevich, rriggs, shade, vpetko Gbp-Pq: Name jdk-8325567.patch --- src/java.base/unix/native/jspawnhelper/jspawnhelper.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/java.base/unix/native/jspawnhelper/jspawnhelper.c b/src/java.base/unix/native/jspawnhelper/jspawnhelper.c index 7f86826f0..cb660b320 100644 --- a/src/java.base/unix/native/jspawnhelper/jspawnhelper.c +++ b/src/java.base/unix/native/jspawnhelper/jspawnhelper.c @@ -62,6 +62,7 @@ void shutItDown() { fprintf(stdout, "only be run as the result of a call to\n"); fprintf(stdout, "ProcessBuilder.start() or Runtime.exec() in a java "); fprintf(stdout, "application\n"); + fflush(stdout); _exit(1); } @@ -142,6 +143,10 @@ int main(int argc, char *argv[]) { /* argv[1] contains the fd number to read all the child info */ int r, fdinr, fdinw, fdout; + if (argc != 2) { + shutItDown(); + } + #ifdef DEBUG jtregSimulateCrash(0, 4); #endif -- 2.30.2