30 #include "runtime/os.hpp"
31 #include "utilities/vmError.hpp"
32
33 #include <signal.h>
34 #include <unistd.h>
35 #include <sys/resource.h>
36 #include <sys/utsname.h>
37 #include <pthread.h>
38 #include <semaphore.h>
39 #include <signal.h>
40
41 // Todo: provide a os::get_max_process_id() or similar. Number of processes
42 // may have been configured, can be read more accurately from proc fs etc.
43 #ifndef MAX_PID
44 #define MAX_PID INT_MAX
45 #endif
46 #define IS_VALID_PID(p) (p > 0 && p < MAX_PID)
47
48 // Check core dump limit and report possible place where core can be found
49 void os::check_dump_limit(char* buffer, size_t bufferSize) {
50 int n;
51 struct rlimit rlim;
52 bool success;
53
54 char core_path[PATH_MAX];
55 n = get_core_path(core_path, PATH_MAX);
56
57 if (n <= 0) {
58 jio_snprintf(buffer, bufferSize, "core.%d (may not exist)", current_process_id());
59 success = true;
60 #ifdef LINUX
61 } else if (core_path[0] == '"') { // redirect to user process
62 jio_snprintf(buffer, bufferSize, "Core dumps may be processed with %s", core_path);
63 success = true;
64 #endif
65 } else if (getrlimit(RLIMIT_CORE, &rlim) != 0) {
66 jio_snprintf(buffer, bufferSize, "%s (may not exist)", core_path);
67 success = true;
68 } else {
69 switch(rlim.rlim_cur) {
|
30 #include "runtime/os.hpp"
31 #include "utilities/vmError.hpp"
32
33 #include <signal.h>
34 #include <unistd.h>
35 #include <sys/resource.h>
36 #include <sys/utsname.h>
37 #include <pthread.h>
38 #include <semaphore.h>
39 #include <signal.h>
40
41 // Todo: provide a os::get_max_process_id() or similar. Number of processes
42 // may have been configured, can be read more accurately from proc fs etc.
43 #ifndef MAX_PID
44 #define MAX_PID INT_MAX
45 #endif
46 #define IS_VALID_PID(p) (p > 0 && p < MAX_PID)
47
48 // Check core dump limit and report possible place where core can be found
49 void os::check_dump_limit(char* buffer, size_t bufferSize) {
50 if (!FLAG_IS_DEFAULT(CreateCoredumpOnCrash) && !CreateCoredumpOnCrash) {
51 jio_snprintf(buffer, bufferSize, "CreateCoredumpOnCrash is disabled from command line");
52 VMError::record_coredump_status(buffer, false);
53 return;
54 }
55
56 int n;
57 struct rlimit rlim;
58 bool success;
59
60 char core_path[PATH_MAX];
61 n = get_core_path(core_path, PATH_MAX);
62
63 if (n <= 0) {
64 jio_snprintf(buffer, bufferSize, "core.%d (may not exist)", current_process_id());
65 success = true;
66 #ifdef LINUX
67 } else if (core_path[0] == '"') { // redirect to user process
68 jio_snprintf(buffer, bufferSize, "Core dumps may be processed with %s", core_path);
69 success = true;
70 #endif
71 } else if (getrlimit(RLIMIT_CORE, &rlim) != 0) {
72 jio_snprintf(buffer, bufferSize, "%s (may not exist)", core_path);
73 success = true;
74 } else {
75 switch(rlim.rlim_cur) {
|