8214300: .attach_pid files may remain in the process cwd
Reviewed-by: sspitsyn, cjplummer, jcbeyler
--- a/src/jdk.attach/aix/classes/sun/tools/attach/VirtualMachineImpl.java Tue Dec 04 07:09:02 2018 -0500
+++ b/src/jdk.attach/aix/classes/sun/tools/attach/VirtualMachineImpl.java Tue Dec 04 07:06:38 2018 -0500
@@ -268,6 +268,7 @@
String path = "/proc/" + pid + "/cwd/" + fn;
File f = new File(path);
try {
+ f = f.getCanonicalFile();
f.createNewFile();
} catch (IOException x) {
f = new File(tmpdir, fn);
--- a/src/jdk.attach/linux/classes/sun/tools/attach/VirtualMachineImpl.java Tue Dec 04 07:09:02 2018 -0500
+++ b/src/jdk.attach/linux/classes/sun/tools/attach/VirtualMachineImpl.java Tue Dec 04 07:06:38 2018 -0500
@@ -283,6 +283,7 @@
String path = "/proc/" + pid + "/cwd/" + fn;
File f = new File(path);
try {
+ f = f.getCanonicalFile();
f.createNewFile();
} catch (IOException x) {
String root;
@@ -295,6 +296,7 @@
root = tmpdir;
}
f = new File(root, fn);
+ f = f.getCanonicalFile();
f.createNewFile();
}
return f;
--- a/src/jdk.attach/solaris/classes/sun/tools/attach/VirtualMachineImpl.java Tue Dec 04 07:09:02 2018 -0500
+++ b/src/jdk.attach/solaris/classes/sun/tools/attach/VirtualMachineImpl.java Tue Dec 04 07:06:38 2018 -0500
@@ -234,6 +234,7 @@
String path = "/proc/" + pid + "/cwd/" + fn;
File f = new File(path);
try {
+ f = f.getCanonicalFile();
f.createNewFile();
} catch (IOException x) {
f = new File(tmpdir, fn);