8267666: Add option to jcmd GC.heap_dump to use existing file

Reviewed-by: rschmelter, clanger
This commit is contained in:
Anton Kozlov 2021-07-12 11:12:52 +00:00
parent 8973867fb9
commit 7cbb67a3f8
11 changed files with 27 additions and 23 deletions

View file

@ -4963,9 +4963,7 @@ int os::open(const char *path, int oflag, int mode) {
// create binary file, rewriting existing file if required
int os::create_binary_file(const char* path, bool rewrite_existing) {
int oflags = O_WRONLY | O_CREAT;
if (!rewrite_existing) {
oflags |= O_EXCL;
}
oflags |= rewrite_existing ? O_TRUNC : O_EXCL;
return ::open64(path, oflags, S_IREAD | S_IWRITE);
}