summaryrefslogtreecommitdiff
path: root/process.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-03-20 23:19:52 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-03-20 23:19:52 +0000
commitf60de59a7058877d69031c45c6ce88a2c11f2130 (patch)
tree75d1c019b52e6a2b803d0bd60fa8d965b7e67525 /process.c
parentba1a12170b972485ee5271d7d84e2b79382f27a9 (diff)
* process.c (rb_exec): prints error message only on platforms
neither close-on-exec nor spawnv is supported. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23024 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'process.c')
-rw-r--r--process.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/process.c b/process.c
index 35b78d9e21..d2290826b7 100644
--- a/process.c
+++ b/process.c
@@ -2336,19 +2336,28 @@ rb_exec_err(const struct rb_exec_arg *e, char *errmsg, size_t errmsg_buflen)
else {
rb_proc_exec_n(argc, argv, prog);
}
-#ifndef FD_CLOEXEC
- preserving_errno({
- fprintf(stderr, "%s:%d: command not found: %s\n",
- rb_sourcefile(), rb_sourceline(), prog);
- });
-#endif
return -1;
}
int
rb_exec(const struct rb_exec_arg *e)
{
+#if !defined FD_CLOEXEC && !defined HAVE_SPAWNV
+ char errmsg[80] = { '\0' };
+ int ret = rb_exec_err(e, errmsg, sizeof(errmsg));
+ preserving_errno(
+ if (errmsg[0]) {
+ fprintf(stderr, "%s\n", errmsg);
+ }
+ else {
+ fprintf(stderr, "%s:%d: command not found: %s\n",
+ rb_sourcefile(), rb_sourceline(), e->prog);
+ }
+ );
+ return ret;
+#else
return rb_exec_err(e, NULL, 0);
+#endif
}
#ifdef HAVE_FORK