8285362: unify os::pause platform coding
Reviewed-by: dholmes, lucy
This commit is contained in:
parent
82f0ac02e0
commit
d8025c95cd
src/hotspot
@ -2805,26 +2805,6 @@ int os::loadavg(double values[], int nelem) {
|
||||
}
|
||||
}
|
||||
|
||||
void os::pause() {
|
||||
char filename[MAX_PATH];
|
||||
if (PauseAtStartupFile && PauseAtStartupFile[0]) {
|
||||
jio_snprintf(filename, MAX_PATH, "%s", PauseAtStartupFile);
|
||||
} else {
|
||||
jio_snprintf(filename, MAX_PATH, "./vm.paused.%d", current_process_id());
|
||||
}
|
||||
|
||||
int fd = ::open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0666);
|
||||
if (fd != -1) {
|
||||
struct stat buf;
|
||||
::close(fd);
|
||||
while (::stat(filename, &buf) == 0) {
|
||||
(void)::poll(NULL, 0, 100);
|
||||
}
|
||||
} else {
|
||||
trcVerbose("Could not open pause file '%s', continuing immediately.", filename);
|
||||
}
|
||||
}
|
||||
|
||||
bool os::is_primordial_thread(void) {
|
||||
if (pthread_self() == (pthread_t)1) {
|
||||
return true;
|
||||
|
@ -2446,27 +2446,6 @@ int os::loadavg(double loadavg[], int nelem) {
|
||||
return ::getloadavg(loadavg, nelem);
|
||||
}
|
||||
|
||||
void os::pause() {
|
||||
char filename[MAX_PATH];
|
||||
if (PauseAtStartupFile && PauseAtStartupFile[0]) {
|
||||
jio_snprintf(filename, MAX_PATH, "%s", PauseAtStartupFile);
|
||||
} else {
|
||||
jio_snprintf(filename, MAX_PATH, "./vm.paused.%d", current_process_id());
|
||||
}
|
||||
|
||||
int fd = ::open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0666);
|
||||
if (fd != -1) {
|
||||
struct stat buf;
|
||||
::close(fd);
|
||||
while (::stat(filename, &buf) == 0) {
|
||||
(void)::poll(NULL, 0, 100);
|
||||
}
|
||||
} else {
|
||||
jio_fprintf(stderr,
|
||||
"Could not open pause file '%s', continuing immediately.\n", filename);
|
||||
}
|
||||
}
|
||||
|
||||
// Get the kern.corefile setting, or otherwise the default path to the core file
|
||||
// Returns the length of the string
|
||||
int os::get_core_path(char* buffer, size_t bufferSize) {
|
||||
|
@ -5116,27 +5116,6 @@ int os::loadavg(double loadavg[], int nelem) {
|
||||
return ::getloadavg(loadavg, nelem);
|
||||
}
|
||||
|
||||
void os::pause() {
|
||||
char filename[MAX_PATH];
|
||||
if (PauseAtStartupFile && PauseAtStartupFile[0]) {
|
||||
jio_snprintf(filename, MAX_PATH, "%s", PauseAtStartupFile);
|
||||
} else {
|
||||
jio_snprintf(filename, MAX_PATH, "./vm.paused.%d", current_process_id());
|
||||
}
|
||||
|
||||
int fd = ::open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0666);
|
||||
if (fd != -1) {
|
||||
struct stat buf;
|
||||
::close(fd);
|
||||
while (::stat(filename, &buf) == 0) {
|
||||
(void)::poll(NULL, 0, 100);
|
||||
}
|
||||
} else {
|
||||
jio_fprintf(stderr,
|
||||
"Could not open pause file '%s', continuing immediately.\n", filename);
|
||||
}
|
||||
}
|
||||
|
||||
// Get the default path to the core file
|
||||
// Returns the length of the string
|
||||
int os::get_core_path(char* buffer, size_t bufferSize) {
|
||||
|
@ -5150,27 +5150,6 @@ bool os::pd_unmap_memory(char* addr, size_t bytes) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void os::pause() {
|
||||
char filename[MAX_PATH];
|
||||
if (PauseAtStartupFile && PauseAtStartupFile[0]) {
|
||||
jio_snprintf(filename, MAX_PATH, "%s", PauseAtStartupFile);
|
||||
} else {
|
||||
jio_snprintf(filename, MAX_PATH, "./vm.paused.%d", current_process_id());
|
||||
}
|
||||
|
||||
int fd = ::open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0666);
|
||||
if (fd != -1) {
|
||||
struct stat buf;
|
||||
::close(fd);
|
||||
while (::stat(filename, &buf) == 0) {
|
||||
Sleep(100);
|
||||
}
|
||||
} else {
|
||||
jio_fprintf(stderr,
|
||||
"Could not open pause file '%s', continuing immediately.\n", filename);
|
||||
}
|
||||
}
|
||||
|
||||
Thread* os::ThreadCrashProtection::_protected_thread = NULL;
|
||||
os::ThreadCrashProtection* os::ThreadCrashProtection::_crash_protection = NULL;
|
||||
|
||||
|
@ -72,6 +72,10 @@
|
||||
#include "utilities/events.hpp"
|
||||
#include "utilities/powerOfTwo.hpp"
|
||||
|
||||
#ifndef _WINDOWS
|
||||
# include <poll.h>
|
||||
#endif
|
||||
|
||||
# include <signal.h>
|
||||
# include <errno.h>
|
||||
|
||||
@ -1416,6 +1420,35 @@ size_t os::page_size_for_region_unaligned(size_t region_size, size_t min_pages)
|
||||
return page_size_for_region(region_size, min_pages, false);
|
||||
}
|
||||
|
||||
#ifndef MAX_PATH
|
||||
#define MAX_PATH (2 * K)
|
||||
#endif
|
||||
|
||||
void os::pause() {
|
||||
char filename[MAX_PATH];
|
||||
if (PauseAtStartupFile && PauseAtStartupFile[0]) {
|
||||
jio_snprintf(filename, MAX_PATH, "%s", PauseAtStartupFile);
|
||||
} else {
|
||||
jio_snprintf(filename, MAX_PATH, "./vm.paused.%d", current_process_id());
|
||||
}
|
||||
|
||||
int fd = ::open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0666);
|
||||
if (fd != -1) {
|
||||
struct stat buf;
|
||||
::close(fd);
|
||||
while (::stat(filename, &buf) == 0) {
|
||||
#if defined(_WINDOWS)
|
||||
Sleep(100);
|
||||
#else
|
||||
(void)::poll(NULL, 0, 100);
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
jio_fprintf(stderr,
|
||||
"Could not open pause file '%s', continuing immediately.\n", filename);
|
||||
}
|
||||
}
|
||||
|
||||
static const char* errno_to_string (int e, bool short_text) {
|
||||
#define ALL_SHARED_ENUMS(X) \
|
||||
X(E2BIG, "Argument list too long") \
|
||||
|
Loading…
x
Reference in New Issue
Block a user