Blame SOURCES/abrt_friendly_hs_log_jdk7.patch

d557d5
--- openjdk/hotspot/src/share/vm/utilities/vmError.cpp	2012-02-02 16:17:24.476664897 +0100
d557d5
+++ openjdk/hotspot/src/share/vm/utilities/vmError.cpp	2012-02-02 16:17:24.476664897 +0100
d557d5
@@ -929,6 +929,7 @@
d557d5
         }
d557d5
       }
d557d5
 
d557d5
+      /*
d557d5
       if (fd == -1) {
d557d5
         const char *cwd = os::get_current_directory(buffer, sizeof(buffer));
d557d5
         size_t len = strlen(cwd);
d557d5
@@ -938,6 +939,24 @@
d557d5
                      os::file_separator(), os::current_process_id());
79d80c
         fd = open(buffer, O_RDWR | O_CREAT | O_EXCL, 0666);
d557d5
       }
d557d5
+      */
d557d5
+
d557d5
+      if (fd == -1) {
d557d5
+        const char * tmpdir = os::get_temp_directory();
d557d5
+        // try temp directory if it exists.
d557d5
+        if (tmpdir != NULL && tmpdir[0] != '\0') {
d557d5
+          jio_snprintf(buffer, sizeof(buffer), "%s%sjvm-%u",
d557d5
+                       tmpdir, os::file_separator(), os::current_process_id());
d557d5
+          // if mkdir() failed, hs_err will be created in temporary directory
d557d5
+          if (!mkdir(buffer, 0700)) { // only read+execute flags are needed
d557d5
+                                      // but we need to write into the directory too
d557d5
+            jio_snprintf(buffer, sizeof(buffer), "%s%sjvm-%u%shs_error.log",
d557d5
+                           tmpdir, os::file_separator(), os::current_process_id(),
d557d5
+                           os::file_separator());
79d80c
+            fd = open(buffer, O_WRONLY | O_CREAT | O_EXCL, 0444); // read-only file 
d557d5
+          }
d557d5
+        }
d557d5
+      }
d557d5
 
d557d5
       if (fd == -1) {
d557d5
         const char * tmpdir = os::get_temp_directory();