From 6120319afdba98b5ff547b870a0260479e8b683c Mon Sep 17 00:00:00 2001
From: Ludvig Janiuk <lujaniuk@openjdk.org>
Date: Fri, 17 Feb 2023 14:57:00 +0000
Subject: [PATCH] 8302226: failure_handler native.core should wait for coredump
 to finish

Reviewed-by: erikj
---
 test/failure_handler/src/share/conf/linux.properties | 7 +++++--
 test/failure_handler/src/share/conf/mac.properties   | 7 +++++--
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/test/failure_handler/src/share/conf/linux.properties b/test/failure_handler/src/share/conf/linux.properties
index bd737039c1e..fe4b1d9d979 100644
--- a/test/failure_handler/src/share/conf/linux.properties
+++ b/test/failure_handler/src/share/conf/linux.properties
@@ -54,8 +54,11 @@ native.stack.args.delimiter=\0
 native.stack.params.repeat=6
 
 # has to be the last command
-native.core.app=kill
-native.core.args=-ABRT %p
+native.core.app=bash
+# The below trick was found on https://stackoverflow.com/a/41613532
+native.core.args=-c\0kill -ABRT %p && tail --pid=%p -f /dev/null
+native.core.args.delimiter=\0
+native.core.timeout=600000
 
 cores=native.gdb
 native.gdb.app=gdb
diff --git a/test/failure_handler/src/share/conf/mac.properties b/test/failure_handler/src/share/conf/mac.properties
index 6cb0c911239..f075178e7eb 100644
--- a/test/failure_handler/src/share/conf/mac.properties
+++ b/test/failure_handler/src/share/conf/mac.properties
@@ -62,8 +62,11 @@ native.stack.params.repeat=6
 native.stack.args=-c\0DevToolsSecurity --status | grep -q enabled && lldb -o 'attach %p' -o 'thread backtrace all' -o 'detach' -o 'quit'
 
 # has to be the last command
-native.core.app=kill
-native.core.args=-ABRT %p
+native.core.app=bash
+# The below trick was found on https://stackoverflow.com/a/41613532
+native.core.args=-c\0kill -ABRT %p && lsof -p %p +r 1 &>/dev/null
+native.core.delimiter=\0
+native.core.timeout=600000
 
 cores=native.lldb
 native.lldb.app=lldb