diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-10-14 15:54:03 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-10-14 15:54:03 +0000 |
commit | 5d4309d068f731a17be791b0dfe6e484a39c25c8 (patch) | |
tree | 2614c9b48018c35c9d631c381cd24a1f148fb475 | |
parent | 0687baaf57ac2fef4ed5406d1a37e05658f8859f (diff) | |
download | ruby-5d4309d068f731a17be791b0dfe6e484a39c25c8.tar.gz |
process.c: use uaspawn
* process.c (proc_exec_cmd): use UTF-8 version aspawn.
[ruby-dev:49838] [Bug #12841]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56424 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | process.c | 6 | ||||
-rw-r--r-- | test/ruby/test_process.rb | 21 |
3 files changed, 32 insertions, 0 deletions
@@ -1,3 +1,8 @@ +Sat Oct 15 00:54:01 2016 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * process.c (proc_exec_cmd): use UTF-8 version aspawn. + [ruby-dev:49838] [Bug #12841] + Fri Oct 14 22:26:10 2016 Nobuyoshi Nakada <nobu@ruby-lang.org> * lib/optparse/kwargs.rb (OptionParser#define_by_keywords): @@ -1247,7 +1247,9 @@ proc_exec_cmd(const char *prog, VALUE argv_str, VALUE envp_str) UNREACHABLE; #else char **argv; +#ifndef _WIN32 char **envp; +#endif argv = ARGVSTR2ARGV(argv_str); @@ -1256,12 +1258,16 @@ proc_exec_cmd(const char *prog, VALUE argv_str, VALUE envp_str) return -1; } +#ifdef _WIN32 + rb_w32_uaspawn(P_OVERLAY, prog, argv); +#else envp = envp_str ? (char **)RSTRING_PTR(envp_str) : NULL; if (envp_str) execve(prog, argv, envp); /* async-signal-safe */ else execv(prog, argv); /* async-signal-safe (since SUSv4) */ preserving_errno(try_with_sh(prog, argv, envp)); /* try_with_sh() is async-signal-safe. */ +#endif return -1; #endif } diff --git a/test/ruby/test_process.rb b/test/ruby/test_process.rb index 28617b60b4..812af7a615 100644 --- a/test/ruby/test_process.rb +++ b/test/ruby/test_process.rb @@ -1910,6 +1910,27 @@ EOS end end if windows? + def test_exec_nonascii + bug12841 = '[ruby-dev:49838] [Bug #12841]' + + [ + "\u{7d05 7389}", + "zuf\u{00E4}llige_\u{017E}lu\u{0165}ou\u{010D}k\u{00FD}_\u{10D2 10D0 10DB 10D4 10DD 10E0 10D4 10D1}_\u{0440 0430 0437 043B 043E 0433 0430}_\u{548C 65B0 52A0 5761 4EE5 53CA 4E1C}", + "c\u{1EE7}a", + ].each do |arg| + begin + arg = arg.encode(Encoding.find("locale")) + rescue + else + assert_in_out_err([], "#{<<-"begin;"}\n#{<<-"end;"}", [arg], [], bug12841) + begin; + arg = "#{arg.b}".force_encoding("#{arg.encoding.name}") + exec(ENV["COMSPEC"]||"cmd.exe", "/c", "echo", arg) + end; + end + end + end if windows? + def test_clock_gettime t1 = Process.clock_gettime(Process::CLOCK_REALTIME, :nanosecond) t2 = Time.now; t2 = t2.tv_sec * 1000000000 + t2.tv_nsec |