code: def _get_process_cwd(pid):
      
  
      cmd = 'lsof -a -p {0} -d cwd -Fn'.format(pid)
  
      data = common.shell_process(cmd)
  
      if not data is None:
          lines = str(data).split('\n')
  
          # the cwd is the second line with 'n' prefix removed from value
          if len(lines) > 1:
              return lines[1][1:] or None
  
      return None
docs: Returns the working directory for the provided process identifier.
  
          `pid`
              System process identifier.
  
          Returns string or ``None``.
  
          Note this is used as a workaround, since `psutil` isn't consistent on
          being able to provide this path in all cases, especially MacOS X.