Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
shirok committed Sep 16, 2024
1 parent e0f0546 commit 678f76f
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/system.c
Original file line number Diff line number Diff line change
Expand Up @@ -1680,12 +1680,6 @@ ScmObj Scm_SysExec(ScmString *file, ScmObj args, ScmObj iomap,
program = Scm_GetStringConst(file);
}

/* Set up environment */
char **envp = NULL;
if (SCM_LISTP(env)) {
envp = Scm_ListToCStringArray(env, TRUE, NULL);
}

/*
* From now on, we have totally different code for Unix and Windows.
*/
Expand Down Expand Up @@ -1728,10 +1722,11 @@ ScmObj Scm_SysExec(ScmString *file, ScmObj args, ScmObj iomap,
Scm_SysSigmask(SIG_SETMASK, mask);
}

if (envp == NULL) {
execv(program, (char *const*)argv);
if (SCM_LISTP(env)) {
execve(program, (char *const*)argv,
Scm_ListToCStringArray(env, TRUE, NULL));
} else {
execve(program, (char *const*)argv, envp);
execv(program, (char *const*)argv);
}
/* here, we failed */
Scm_Panic("exec failed: %s: %s", program, strerror(errno));
Expand Down

0 comments on commit 678f76f

Please sign in to comment.