process_util.hpp file
Safe helpers for locating and spawning external tools.
gtopt runs a few optional external helpers (gtopt_check_lp, gtopt_check_json, gtopt_compress_lp, zstd/gzip, ...). The helpers here centralise the low-level POSIX calls that need care:
- find_trusted_executable(): resolve a tool name without a shell. The directory of the running executable is searched first (a tool that ships with gtopt wins over anything on PATH), then only absolute PATH entries that are not world-writable. Empty, relative ("." or "") and world-writable PATH entries are skipped, so a binary planted in the current working directory or a shared scratch directory is never run by accident.
- spawn_environment(): the environment block handed to posix_spawn.
- create_exclusive_file(): create a new, empty, owner-only file that must not exist yet (never follows a pre-existing symlink).
- gtopt_environment() / log_gtopt_environment(): the
GTOPT_*variables that change behaviour, logged once at start-up.
Namespaces
- namespace gtopt