Mercurial > hg > graal-jvmci-8
comparison src/os/bsd/vm/perfMemory_bsd.cpp @ 23455:9f8038f83a6e
8130910: hsperfdata file is created in wrong directory and not cleaned up if /tmp/hsperfdata_<username> has wrong permissions
Summary: Add check for fchir() failure and disable shared PerfMemory in that case.
Reviewed-by: dcubed, simonis, gthornbr
author | clanger |
---|---|
date | Tue, 17 Nov 2015 09:39:45 -0800 |
parents | f3ffb37f88a6 |
children | 2d23269a45a0 |
comparison
equal
deleted
inserted
replaced
23454:714096aec397 | 23455:9f8038f83a6e |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
373 *saved_cwd_fd = -1; | 373 *saved_cwd_fd = -1; |
374 } else { | 374 } else { |
375 *saved_cwd_fd = result; | 375 *saved_cwd_fd = result; |
376 } | 376 } |
377 | 377 |
378 // Set the current directory to dirname by using the fd of the directory. | 378 // Set the current directory to dirname by using the fd of the directory and |
379 // handle errors, otherwise shared memory files will be created in cwd. | |
379 result = fchdir(fd); | 380 result = fchdir(fd); |
380 | 381 if (result == OS_ERR) { |
381 return dirp; | 382 if (PrintMiscellaneous && Verbose) { |
383 warning("could not change to directory %s", dirname); | |
384 } | |
385 if (*saved_cwd_fd != -1) { | |
386 ::close(*saved_cwd_fd); | |
387 *saved_cwd_fd = -1; | |
388 } | |
389 // Close the directory. | |
390 os::closedir(dirp); | |
391 return NULL; | |
392 } else { | |
393 return dirp; | |
394 } | |
382 } | 395 } |
383 | 396 |
384 // Close the directory and restore the current working directory. | 397 // Close the directory and restore the current working directory. |
385 // | 398 // |
386 static void close_directory_secure_cwd(DIR* dirp, int saved_cwd_fd) { | 399 static void close_directory_secure_cwd(DIR* dirp, int saved_cwd_fd) { |