@Nullable
  private static String doGetCwd(@NotNull Process process) throws Exception {
    if (SystemInfo.isUnix) {
      int pid = (int)process.pid();
      String result = tryGetCwdFastOnUnix(pid);
      if (result != null) {
        return result;
      }
      return getCwdOnUnix(pid);
    }
    else if (SystemInfo.isWindows) {
      if (process instanceof WinPtyProcess) {
        return ((WinPtyProcess)process).getWorkingDirectory();
      }
      if (process instanceof WinConPtyProcess) {
        return ((WinConPtyProcess)process).getWorkingDirectory();
      }
      throw new IllegalStateException("Cwd cannot be fetched for " + process.getClass());
    }
    throw new IllegalStateException("Unsupported OS: " + SystemInfo.OS_NAME);
  }
@Nullable
  private static String doGetCwd(@NotNull Process process)