ForegroundPID(*os.File) returns a terminal's foreground process group ID; Directory(pid) reads a process's working directory. Both return errors, leave file ownership with the caller, and do not invoke a shell. macOS uses libproc and tcgetpgrp; Linux uses /proc and terminal ioctl. Other platforms return native.ErrUnsupported. Invalid arguments return native.ErrInvalidArgument; disappearing processes and non-terminal descriptors return native.ErrFailed.
Dependencies: native, native/internal/sys. No UI or Gio dependencies. Platform bindings remain inside native/internal/sys.
Package process provides terminal foreground process and working-directory
queries without a UI dependency. macOS and Linux are supported; other builds
return native.ErrUnsupported. Query results may change as processes exit.
ForegroundPID returns a terminal's foreground process group ID. On Unix this
is the group leader PID, not necessarily the deepest running child process.
The caller retains ownership of terminal and must keep it open during the call.