8289910: unify os::message_box across posix platforms

Reviewed-by: iklam, dholmes
This commit is contained in:
Matthias Baesken 2022-07-12 12:10:28 +00:00
parent 04c47da118
commit e5491a2605
4 changed files with 20 additions and 57 deletions

View File

@ -2467,25 +2467,6 @@ os::os_exception_wrapper(java_call_t f, JavaValue* value, const methodHandle& me
void os::print_statistics() {
}
bool os::message_box(const char* title, const char* message) {
int i;
fdStream err(defaultStream::error_fd());
for (i = 0; i < 78; i++) err.print_raw("=");
err.cr();
err.print_raw_cr(title);
for (i = 0; i < 78; i++) err.print_raw("-");
err.cr();
err.print_raw_cr(message);
for (i = 0; i < 78; i++) err.print_raw("=");
err.cr();
char buf[16];
// Prevent process from exiting upon "read error" without consuming all CPU
while (::read(0, buf, sizeof(buf)) <= 0) { ::sleep(100); }
return buf[0] == 'y' || buf[0] == 'Y';
}
// This code originates from JDK's sysOpen and open64_w
// from src/solaris/hpi/src/system_md.c

View File

@ -2161,25 +2161,6 @@ void os::os_exception_wrapper(java_call_t f, JavaValue* value,
void os::print_statistics() {
}
bool os::message_box(const char* title, const char* message) {
int i;
fdStream err(defaultStream::error_fd());
for (i = 0; i < 78; i++) err.print_raw("=");
err.cr();
err.print_raw_cr(title);
for (i = 0; i < 78; i++) err.print_raw("-");
err.cr();
err.print_raw_cr(message);
for (i = 0; i < 78; i++) err.print_raw("=");
err.cr();
char buf[16];
// Prevent process from exiting upon "read error" without consuming all CPU
while (::read(0, buf, sizeof(buf)) <= 0) { ::sleep(100); }
return buf[0] == 'y' || buf[0] == 'Y';
}
static inline struct timespec get_mtime(const char* filename) {
struct stat st;
int ret = os::stat(filename, &st);

View File

@ -4814,25 +4814,6 @@ os::os_exception_wrapper(java_call_t f, JavaValue* value, const methodHandle& me
void os::print_statistics() {
}
bool os::message_box(const char* title, const char* message) {
int i;
fdStream err(defaultStream::error_fd());
for (i = 0; i < 78; i++) err.print_raw("=");
err.cr();
err.print_raw_cr(title);
for (i = 0; i < 78; i++) err.print_raw("-");
err.cr();
err.print_raw_cr(message);
for (i = 0; i < 78; i++) err.print_raw("=");
err.cr();
char buf[16];
// Prevent process from exiting upon "read error" without consuming all CPU
while (::read(0, buf, sizeof(buf)) <= 0) { ::sleep(100); }
return buf[0] == 'y' || buf[0] == 'Y';
}
// This code originates from JDK's sysOpen and open64_w
// from src/solaris/hpi/src/system_md.c

View File

@ -45,6 +45,7 @@
#include "runtime/park.hpp"
#include "runtime/perfMemory.hpp"
#include "utilities/align.hpp"
#include "utilities/defaultStream.hpp"
#include "utilities/events.hpp"
#include "utilities/formatBuffer.hpp"
#include "utilities/globalDefinitions.hpp"
@ -1930,6 +1931,25 @@ int os::fork_and_exec(const char* cmd) {
}
}
bool os::message_box(const char* title, const char* message) {
int i;
fdStream err(defaultStream::error_fd());
for (i = 0; i < 78; i++) err.print_raw("=");
err.cr();
err.print_raw_cr(title);
for (i = 0; i < 78; i++) err.print_raw("-");
err.cr();
err.print_raw_cr(message);
for (i = 0; i < 78; i++) err.print_raw("=");
err.cr();
char buf[16];
// Prevent process from exiting upon "read error" without consuming all CPU
while (::read(0, buf, sizeof(buf)) <= 0) { ::sleep(100); }
return buf[0] == 'y' || buf[0] == 'Y';
}
////////////////////////////////////////////////////////////////////////////////
// runtime exit support