1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-21 21:52:10 +02:00

Bug 563015: Log exception if process.pid() fails

Change-Id: Ie9888e1e56b19086890caf221f0cbd97eafa817c
This commit is contained in:
Jonah Graham 2021-04-23 11:21:16 -04:00
parent e033c50e28
commit 6386faff0d

View file

@ -306,14 +306,18 @@ public class ProcessConnector extends AbstractStreamsConnector {
*/
@Override
public Optional<String> getWorkingDirectory() {
long pid = process.pid();
try {
if (Platform.getOS().equals(Platform.OS_LINUX)) {
Path procCwd = Files.readSymbolicLink(FileSystems.getDefault().getPath("/proc/" + pid + "/cwd")); //$NON-NLS-1$//$NON-NLS-2$
return Optional.of(procCwd.toAbsolutePath().toString());
long pid = process.pid();
try {
if (Platform.getOS().equals(Platform.OS_LINUX)) {
Path procCwd = Files.readSymbolicLink(FileSystems.getDefault().getPath("/proc/" + pid + "/cwd")); //$NON-NLS-1$//$NON-NLS-2$
return Optional.of(procCwd.toAbsolutePath().toString());
}
} catch (Exception e) {
UIPlugin.log("Failed to obtain working directory of process id " + pid, e); //$NON-NLS-1$
}
} catch (Exception e) {
UIPlugin.log("Failed to obtain working directory of process id " + pid, e); //$NON-NLS-1$
UIPlugin.log("Failed to obtain process id of terminal process", e); //$NON-NLS-1$
}
return Optional.empty();
}