Minor fixes of Wunused_var, environment copy on subprocess creation

This commit is contained in:
zx
2024-05-14 00:00:37 +03:00
parent 30e860885f
commit 097b39faa7
5 changed files with 45 additions and 6 deletions
+12
View File
@@ -26,6 +26,8 @@ struct {
{ NULL, 0 }
};
extern char **environ;
int exec_file_exist(const char *command)
{
const char *p;
@@ -73,9 +75,19 @@ int exec_options_parse(char *str)
void exec_options_init(s_exec_options *eopt)
{
char ** env;
int i;
memset(eopt, '\0', sizeof(s_exec_options));
eopt->umask = EXEC_DEFAULT_UMASK;
env = environ;
eopt->envp[0] = NULL;
for (i=0; env[i]; i++) {
log("EXEC: Added ENV variable: %s\n", env[i]);
eopt->envp[i] = xmalloc(strlen(env[i]) + 2);
sprintf(eopt->envp[i], env[i]);
eopt->envp[i+1] = NULL;
}
}
void exec_options_deinit(s_exec_options *eopt)