qlibs:(pathexec)
π NAME π
okay so this is the glow-up of qlibs:(pathexec) π«Ά and the star of the page is pathexec β it literally runs a program within a given environment. bestie, it's giving "launch this program, but with the exact env you want" β¨
β¨ SYNTAX β¨
#include "pathexec.h"
pathexec_run(const char *p,char **a,char **e);
pathexec(char *const *a);
pathexec_env(const char *s,char *t);
π¦ DESCRIPTION π¦
okay so pathexec_run searches for a program named p π. then it replaces the current process with a copy of that program β like a full main-character takeover π
. the main function in that program will be given arguments a and environment e.
pathexec_run looks for p as specified by the $PATH environment variable. $PATH is a colon-separated list of directories d; pathexec_run tries execve on files named d/p, in the order that the directories appear inside $PATH. an empty directory name is treated as a single dot. periodt.
if $PATH is not set, pathexec_run uses the path /bin:/usr/bin; i.e., it tries execve on /bin/p, then /usr/bin/p. no cap.
if p contains a slash, pathexec_run ignores $PATH and simply runs execve on a file named p. slay, direct route π£οΈ.
pathexec calls pathexec_run with program name a[0], arguments a, and the same environment as the current process, modified as described below. pathexec has the same return behavior as pathexec_run.
pathexec_env modifies the environment used by pathexec. it removes a variable named s, if one exists. then it adds a variable named s with value t, if the pointer t is nonzero. the name s must not contain =. π¨
π₯ RETURN CODES π₯
normally pathexec_run does not return, because the process has been replaced β it's gone, bye π. however, if all the execve attempts fail, pathexec_run returns, setting errno to the most interesting error returned by execve.
furthermore, pathexec_run returns immediately if an execve attempt fails with an error other than error_noent, error_acces, error_perm, or error_isdir. this list is subject to change β so don't come for me if it shifts, bestie π.
normally pathexec_env returns 1. if it is unable to allocate memory, it returns 0, leaving the pathexec environment alone. lowkey important: that's a no-touch situation π«Ά.
π SEE ALSO π
error(3)β go read that one too, iykyk π
cute sign-off: this page is from qlibs:(pathexec), section 3 β¨ mwah, bestie β go run something iconic π
π¦ where this page comes from
- alpine 3.24: fehqlibs-doc 31-r0 Β· Public-Domain
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms