mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
fix build on no-fork-spawnv platforms
* process.c (rb_execarg_commandline): build command line string from argument vector in rb_execarg. [ruby-core:75611] [Bug #12398] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55091 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
cbde995b2f
commit
aa107497cd
3 changed files with 36 additions and 14 deletions
|
@ -1,3 +1,9 @@
|
|||
Sat May 21 00:36:32 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* process.c (rb_execarg_commandline): build command line string
|
||||
from argument vector in rb_execarg.
|
||||
[ruby-core:75611] [Bug #12398]
|
||||
|
||||
Fri May 20 23:25:42 2016 Kazuki Yamaguchi <k@rhe.jp>
|
||||
|
||||
* ext/openssl/ossl.c (ossl_pem_passwd_value): Added. Convert the
|
||||
|
|
11
io.c
11
io.c
|
@ -5886,6 +5886,8 @@ rb_execarg_fixup_v(VALUE execarg_obj)
|
|||
rb_execarg_parent_start(execarg_obj);
|
||||
return Qnil;
|
||||
}
|
||||
#else
|
||||
char *rb_execarg_commandline(const struct rb_execarg *eargp, VALUE *prog);
|
||||
#endif
|
||||
|
||||
static VALUE
|
||||
|
@ -5933,10 +5935,6 @@ pipe_open(VALUE execarg_obj, const char *modestr, int fmode,
|
|||
int write_fd = -1;
|
||||
#if !defined(HAVE_WORKING_FORK)
|
||||
const char *cmd = 0;
|
||||
#if !defined(HAVE_SPAWNV)
|
||||
int argc;
|
||||
VALUE *argv;
|
||||
#endif
|
||||
|
||||
if (prog)
|
||||
cmd = StringValueCStr(prog);
|
||||
|
@ -6065,10 +6063,7 @@ pipe_open(VALUE execarg_obj, const char *modestr, int fmode,
|
|||
fd = arg.pair[1];
|
||||
}
|
||||
#else
|
||||
if (argc) {
|
||||
prog = rb_ary_join(rb_ary_new4(argc, argv), rb_str_new2(" "));
|
||||
cmd = StringValueCStr(prog);
|
||||
}
|
||||
cmd = rb_execarg_commandline(eargp, &prog);
|
||||
if (!NIL_P(execarg_obj)) {
|
||||
rb_execarg_parent_start(execarg_obj);
|
||||
rb_execarg_run_options(eargp, sargp, NULL, 0);
|
||||
|
|
33
process.c
33
process.c
|
@ -3902,6 +3902,29 @@ rb_syswait(rb_pid_t pid)
|
|||
rb_waitpid(pid, &status, 0);
|
||||
}
|
||||
|
||||
#if !defined HAVE_WORKING_FORK && !defined HAVE_SPAWNV
|
||||
char *
|
||||
rb_execarg_commandline(const struct rb_execarg *eargp, VALUE *prog)
|
||||
{
|
||||
VALUE cmd = *prog;
|
||||
if (eargp && !eargp->use_shell) {
|
||||
VALUE str = eargp->invoke.cmd.argv_str;
|
||||
VALUE buf = eargp->invoke.cmd.argv_buf;
|
||||
char *p, **argv = ARGVSTR2ARGV(str);
|
||||
long i, argc = ARGVSTR2ARGC(str);
|
||||
const char *start = RSTRING_PTR(buf);
|
||||
cmd = rb_str_new(start, RSTRING_LEN(buf));
|
||||
p = RSTRING_PTR(cmd);
|
||||
for (i = 1; i < argc; ++i) {
|
||||
p[argv[i] - start - 1] = ' ';
|
||||
}
|
||||
*prog = cmd;
|
||||
return p;
|
||||
}
|
||||
return StringValueCStr(*prog);
|
||||
}
|
||||
#endif
|
||||
|
||||
static rb_pid_t
|
||||
rb_spawn_process(struct rb_execarg *eargp, char *errmsg, size_t errmsg_buflen)
|
||||
{
|
||||
|
@ -3909,6 +3932,9 @@ rb_spawn_process(struct rb_execarg *eargp, char *errmsg, size_t errmsg_buflen)
|
|||
#if !defined HAVE_WORKING_FORK || USE_SPAWNV
|
||||
VALUE prog;
|
||||
struct rb_execarg sarg;
|
||||
# if !defined HAVE_SPAWNV
|
||||
int status;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined HAVE_WORKING_FORK && !USE_SPAWNV
|
||||
|
@ -3935,12 +3961,7 @@ rb_spawn_process(struct rb_execarg *eargp, char *errmsg, size_t errmsg_buflen)
|
|||
if (pid == -1)
|
||||
rb_last_status_set(0x7f << 8, 0);
|
||||
# else
|
||||
if (!eargp->use_shell) {
|
||||
char **argv = ARGVSTR2ARGV(eargp->invoke.cmd.argv_str);
|
||||
int argc = ARGVSTR2ARGC(eargp->invoke.cmd.argv_str);
|
||||
prog = rb_ary_join(rb_ary_new4(argc, argv), rb_str_new2(" "));
|
||||
}
|
||||
status = system(StringValuePtr(prog));
|
||||
status = system(rb_execarg_commandline(eargp, &prog));
|
||||
rb_last_status_set((status & 0xff) << 8, 0);
|
||||
pid = 1; /* dummy */
|
||||
# endif
|
||||
|
|
Loading…
Reference in a new issue