From f60de59a7058877d69031c45c6ce88a2c11f2130 Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 20 Mar 2009 23:19:52 +0000 Subject: [PATCH] * 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 --- ChangeLog | 5 +++++ process.c | 21 +++++++++++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index bbbf65aba7..7d312ddb84 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sat Mar 21 08:19:52 2009 Nobuyoshi Nakada + + * process.c (rb_exec): prints error message only on platforms + neither close-on-exec nor spawnv is supported. + Sat Mar 21 08:17:41 2009 Nobuyoshi Nakada * win32/win32.c (rb_w32_spawn, rb_w32_aspawn): omit program name 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