summaryrefslogtreecommitdiff
path: root/process.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-06-08 16:26:01 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-06-08 16:26:01 +0000
commit2fb032b74be9f306fbd2f95d85f8352f4a6027d6 (patch)
treebc48fc336314f0d254dcb4dda6310138611b10db /process.c
parentbf4ecf1d1a79a36cace3655e79631e8268fd36da (diff)
* process.c (rb_exec_err): before_exec() call moved from proc_exec_cmd
and proc_exec_sh. (rb_proc_exec): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35969 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'process.c')
-rw-r--r--process.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/process.c b/process.c
index 2e7b31f2a3..3bd8c75732 100644
--- a/process.c
+++ b/process.c
@@ -1111,7 +1111,6 @@ proc_exec_cmd(const char *prog, VALUE argv_str, VALUE envp_str)
}
}
# endif /* __EMX__ */
- before_exec(); /* async-signal-safe if forked_child is true */
envp = envp_str ? (char **)RSTRING_PTR(envp_str) : NULL;
if (envp_str)
execve(prog, argv, envp); /* async-signal-safe */
@@ -1136,6 +1135,7 @@ proc_exec_sh(const char *str, VALUE envp_str)
rb_notimplement();
UNREACHABLE;
#else
+
while (*str == ' ' || *str == '\t' || *str == '\n')
str++;
@@ -1145,7 +1145,6 @@ proc_exec_sh(const char *str, VALUE envp_str)
}
#ifdef _WIN32
- before_exec();
rb_w32_spawn(P_OVERLAY, (char *)str, 0);
return -1;
#else
@@ -1154,7 +1153,6 @@ proc_exec_sh(const char *str, VALUE envp_str)
char fbuf[MAXPATHLEN];
char *shell = dln_find_exe_r("sh", 0, fbuf, sizeof(fbuf));
int status = -1;
- before_exec();
if (shell)
execl(shell, "sh", "-c", str, (char *) NULL);
else
@@ -1163,7 +1161,6 @@ proc_exec_sh(const char *str, VALUE envp_str)
exit(status);
}
#else
- before_exec(); /* async-signal-safe if forked_child is true. */
if (envp_str)
execle("/bin/sh", "sh", "-c", str, (char *)NULL, (char **)RSTRING_PTR(envp_str)); /* async-signal-safe */
else
@@ -2596,8 +2593,10 @@ rb_exec_err(const struct rb_exec_arg *e, char *errmsg, size_t errmsg_buflen)
# define sargp NULL
#endif
+ before_exec(); /* async-signal-safe if forked_child is true */
+
if (rb_run_exec_options_err(e, sargp, errmsg, errmsg_buflen) < 0) { /* async-signal-safe */
- return -1;
+ goto failure;
}
if (e->use_shell) {
@@ -2614,6 +2613,7 @@ rb_exec_err(const struct rb_exec_arg *e, char *errmsg, size_t errmsg_buflen)
#else
# undef sargp
#endif
+failure:
preserving_errno(after_exec()); /* xxx: not async-signal-safe because after_exec calls rb_thread_start_timer_thread. */
return -1;
}