Skip to content

Commit

Permalink
8289910: unify os::message_box across posix platforms
Browse files Browse the repository at this point in the history
Backport-of: e5491a2605177a9dca87a060d99aa5ea4fd4a239
  • Loading branch information
MBaesken committed Aug 17, 2022
1 parent 92571e3 commit cb294d9
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 57 deletions.
19 changes: 0 additions & 19 deletions src/hotspot/os/aix/os_aix.cpp
Expand Up @@ -2538,25 +2538,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

Expand Down
19 changes: 0 additions & 19 deletions src/hotspot/os/bsd/os_bsd.cpp
Expand Up @@ -2239,25 +2239,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);
Expand Down
19 changes: 0 additions & 19 deletions src/hotspot/os/linux/os_linux.cpp
Expand Up @@ -4908,25 +4908,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

Expand Down
20 changes: 20 additions & 0 deletions src/hotspot/os/posix/os_posix.cpp
Expand Up @@ -45,6 +45,7 @@
#include "runtime/orderAccess.hpp"
#include "runtime/perfMemory.hpp"
#include "utilities/align.hpp"
#include "utilities/defaultStream.hpp"
#include "utilities/events.hpp"
#include "utilities/formatBuffer.hpp"
#include "utilities/macros.hpp"
Expand Down Expand Up @@ -1995,6 +1996,25 @@ int os::fork_and_exec(const char* cmd, bool prefer_vfork) {
}
}

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

Expand Down

0 comments on commit cb294d9

Please sign in to comment.