diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-05-12 14:15:32 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-05-12 14:15:32 +0000 |
commit | 9416fedc282b6bd96fe1f150833db3e365029767 (patch) | |
tree | cd9feecdfda313004ce5e2e7858a390707c46305 /io.c | |
parent | fe7dae730f070b6fe0e49d41179ff4d86008cca6 (diff) | |
download | ruby-9416fedc282b6bd96fe1f150833db3e365029767.tar.gz |
* process.c, include/ruby/intern.h (rb_run_exec_options): externed.
* process.c (save_redirect_fd, save_env_i, save_env, run_exec_dup2,
run_exec_open, run_exec_pgroup, run_exec_rlimit, rb_run_exec_options):
save parent's process environments.
!!!remark!!! these are not thread-safe.
* process.c (rb_spawn_internal): remove calling run_exec_options()
because cannot restore after spawn. we'll fix this later.
* io.c (pipe_open): ditto.
* test/ruby/test_process.rb (test_execopts_env): upcase environment
variable name for case insensitive platforms.
* win32/win32.c (init_env): set USER environment variable only when
USERNAME is available.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16395 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r-- | io.c | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -3692,6 +3692,7 @@ pipe_open(struct rb_exec_arg *eargp, VALUE prog, const char *mode) int openmode = rb_io_mode_modenum(mode); const char *exename = NULL; volatile VALUE cmdbuf; + struct rb_exec_arg sarg; #endif FILE *fp = 0; int fd = -1; @@ -3822,6 +3823,10 @@ pipe_open(struct rb_exec_arg *eargp, VALUE prog, const char *mode) cmd = rb_w32_join_argv(RSTRING_PTR(cmdbuf), args); rb_str_resize(argbuf, 0); } + if (eargp) { + rb_exec_arg_fixup(eargp); + rb_run_exec_options(eargp, &sarg); + } while ((pid = rb_w32_pipe_exec(cmd, exename, openmode, &fd, &write_fd)) == -1) { /* exec failed */ switch (errno) { @@ -3832,16 +3837,26 @@ pipe_open(struct rb_exec_arg *eargp, VALUE prog, const char *mode) rb_thread_sleep(1); break; default: + if (eargp) + rb_run_exec_options(&sarg, NULL); rb_sys_fail(cmd); break; } } + if (eargp) + rb_run_exec_options(&sarg, NULL); #else if (argc) { prog = rb_ary_join(rb_ary_new4(argc, argv), rb_str_new2(" ")); cmd = StringValueCStr(prog); } + if (eargp) { + rb_exec_arg_fixup(eargp); + rb_run_exec_options(eargp, &sarg); + } fp = popen(cmd, mode); + if (eargp) + rb_run_exec_options(&sarg, NULL); if (!fp) rb_sys_fail(RSTRING_PTR(prog)); fd = fileno(fp); #endif |