We are running a java application under java 1.6.0_13. When it crashes it creates the normal hs_err_pid file. I don't want this file created even if the application crashes. Is there a way on the java command line to suppress this? I am familiar with -XX:ErrorFile option. If I set this to an empty string will that suppress it?
Asked
Active
Viewed 6,789 times
5
-
You could probably test it out by causing a JVM crash via JNI (just create a little C library that segfaults) or something similar. Feels kind of gross considering suppressing log output for such a critical failure as a JVM crash though. – Mark Peters Nov 10 '10 at 21:25
-
If using Linux you can use the command `kill` to send a `SIGSEGV` signal to test your fix. – Jul 21 '11 at 09:41
2 Answers
6
If you are using a Unix/Linux system, try setting -XX:ErrorFile
to /dev/null
(or, if you are using Windows, try NUL
).

Matt Solnit
- 32,152
- 8
- 53
- 57
-
in which config file do I have to set -XX:ErrorFile to /dev/null in linux ? – Martin Vegter May 10 '18 at 08:36
-
4
With Oracle HotSpot (since 6b21
) and OpenJDK, the -XX:+SuppressFatalErrorMessage
option should be used for preventing creation of the hs_err_pid
file.
Nowadays, using -XX:ErrorFile=/dev/null
will actually not work as expected, since if the file path specified to ErrorFile
exists, the JVM will not attempt to overwrite it and will fall back to the default hs_err_pid
location (there's no special case handling for /dev/null
).
For more details, see also:
- Why java ignored the option “-XX:ErrorFile=/dev/null”?
- Oracle ticket, JDK-6194668: Add java runtime flag
SuppressFatalErrorMessage
to skip all error handling logic on fatal error - OpenJDK ticket, JDK-8189672:
-XX:ErrorFile
doesn't work.

valiano
- 16,433
- 7
- 64
- 79