public static @Nullable String getWorkingDirectory(@NotNull TerminalWidget widget) {
    ProcessTtyConnector connector = ShellTerminalWidget.getProcessTtyConnector(widget.getTtyConnector());
    if (connector == null) return null;
    try {
      long startNano = System.nanoTime();
      Future<String> cwd = ProcessInfoUtil.getCurrentWorkingDirectory(connector.getProcess());
      String result = cwd.get(FETCH_WAIT_MILLIS, TimeUnit.MILLISECONDS);
      boolean exists = checkDirectory(result);
      if (LOG.isDebugEnabled()) {
        LOG.debug("Cwd (" + result + ", exists=" + exists + ") fetched in " + TimeoutUtil.getDurationMillis(startNano) + " ms");
      }
      return exists ? result : null;
    }
    catch (InterruptedException ignored) {
    }
    catch (ExecutionException e) {
      String message = "Failed to fetch cwd for " + widget.getTerminalTitle().buildTitle();
      if (LOG.isDebugEnabled()) {
        LOG.warn(message, e);
      }
      else {
        LOG.warn(message + ": " + e.getCause().getMessage());
      }
    }
    catch (TimeoutException e) {
      LOG.warn("Timeout fetching cwd for " + widget.getTerminalTitle().buildTitle(), e);
    }
    return null;
  }
public static @Nullable String getWorkingDirectory(@NotNull TerminalWidget widget)