0

I want to prevent JVM generating crash log files, so my startup script looks like this

java -XX:ErrorFile=/dev/null MyClass

but when a jvm crash occurs, the log file 'hs_err_pidXXXXX.log' is still generated in current working directory. why ?

OS: ubuntu 18.04, java version: oracle java 10

LCY
  • 35
  • 4

1 Answers1

1

If the file specified to -XX:ErrorFile exists, or can't be opened, then the JVM falls back to the default hs_err_pid error file path. Since /dev/null probably exists, that could explain this behaviour.

I've browsed the OpenJDK JVM source code, corresponding to Oracle's HotSpot, and there doesn't seem to be any special handling of /dev/null in the error reporting code in this respect.

For more details and comments from JVM maintainers, see this OpenJDK bug report: https://bugs.openjdk.java.net/browse/JDK-8189672

valiano
  • 16,433
  • 7
  • 64
  • 79
  • 1
    Perfectly explained. I'd only add a couple options to work around that. `-XX:+SuppressFatalErrorMessage` disables error reporting altogether. It's also possible to remove the log file right after creation: `-XX:OnError="rm hs_err_pid%p.log"` – apangin Dec 16 '18 at 03:09