execprocess#
Functions
-
int exec_process(const char *pathname, char *const argv[], char *const env[])#
Execute
pathnamein a new process.Arguments:
pathname: path to executable.
argv: arguments passed to the process. It is a NULL-terminated array of pointers to NUL-terminated strings. The first argument should point to
pathname.env: environment variables passed to the process. It is a NULL-terminated array of pointers to NUL-terminated strings.
-
char **get_environment(void)#
Returns a pointer to the environment of the current process.
The returned value is a pointer to a NULL-terminated array of pointers to NUL-terminated strings, where each string is of the form “name=value”.
The returned environment must be free’ed with strlist_free().
Returns NULL on error.
-
char **get_envitem(char **env, const char *name)#
Returns a pointer to the
name=valueitem in environmentenvcorresponding to environment variablename, or NULL ifnameisn’t in the environment.
-
char *get_envvar(char **env, const char *name)#
Returns value of environment variable
nameor NULL if it doesn’t exists.
-
char **set_envitem(char **env, const char *item)#
Sets environment variable NAME to
item, whereitemis a NAME=VALUE pair. If it exists from before, it is overwritten. Only call this on an malloc’ed environment, like the one returned by get_environment().If
envis NULL, a new environment is allocated.Returns a pointer to the (possible reallocated) environment or NULL on error.
-
char **set_envvar(char **env, const char *name, const char *value)#
Sets environment variable
nametovalue. If it exists from before, it is overwritten. Only call this on an malloc’ed environment, like the one returned by get_environment().If
envis NULL, a new environment is allocated;Returns a pointer to the (possible reallocated) environment or NULL on error.
-
char **strlist_copy(char **strlist)#
Returns a copy of
strlistor NULL on error.
-
char **strlist_add(char **strlist, const char *s)#
Appends
sto string liststrlistand return a pointer to the reallocated list. Ifstrlistis NULL, a new string list is created.Returns NULL on error.
-
void strlist_free(char **strlist)#
Frees a string list.