Граф коммитов

681 Коммитов

Автор SHA1 Сообщение Дата
ko1 f6f388a5bd * array.c, enum.c, insns.def, io.c, numeric.c, parse.y, process.c,
range.c: use prepared IDs.
  A patch from charliesome (Charlie Somerville).
  [Bug #7495]
* common.mk: add dependency to id.h.
* common.mk: replace ID_H_INCLUDES with id.h.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38143 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-02 09:57:47 +00:00
kosaki 5611df706e * process.c (proc_getsid): adds new method for getting session id.
Contributed from fumiyas (Fumiyasu SATOH). Thank you!
  [Feature #6757] [ruby-dev:45977]
* configure.in: adds getsid check.
* test/ruby/test_process.rb (TestProcess#test_setsid): new test
  for the above.
* NEWS: news for the above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37825 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-24 02:51:24 +00:00
usa ee2718039c * process.c (redirect_dup2): set standard handles when new fd is stdio,
because if there is no allocated console at the moment Windows does
  not automatically associate it for child process's standard handle.
  this is adhoc workaround.
  reported by Martin Thiede at [ruby-core:48542] [Bug #7239].

* io.c (rb_cloexec_dup2): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37388 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-30 10:32:56 +00:00
akr 7206f9bc79 * process.c (posix_sh_cmds): the command name of colon is ":".
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37166 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-12 11:41:40 +00:00
nobu dd83dd6bda process.c: uid gid exec options
* process.c (rb_execarg_addopt, rb_execarg_run_options): add :uid and
  :gid options.  [ruby-core:47414] [Feature #6975]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37124 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-09 08:13:29 +00:00
naruse aa8dd0290b * process.c: exec() requires to be single threaded also on Haiku.
by Takashi Toyoshima <toyoshim@gmail.com>
  https://github.com/ruby/ruby/pull/178

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36940 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-09-09 15:17:15 +00:00
akr e7ddd1fdc3 * internal.h (rb_last_status_clear): declared.
* process.c (rb_last_status_clear): exported.
  (rb_f_system): call rb_last_status_clear.

* io.c (rb_f_backquote): call rb_last_status_clear.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36849 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-29 14:44:08 +00:00
akr 7c854d6d5e * process.c (rb_f_system): check failures of waitpid.
[ruby-talk:398687]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36848 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-29 13:02:45 +00:00
nobu 2933909caf remove trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36799 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-23 07:45:46 +00:00
nobu c05e6a8cda process.c: try conversion at redirection
* io.c (rb_io_check_io): make public.
* process.c (check_exec_redirect): try conversion to IO on redirect
  parameters.  [ruby-core:44181] [Bug #6269]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36551 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-27 09:25:54 +00:00
ko1 f4a8db647a * thread.c (rb_thread_s_control_interrupt,
rb_thread_s_check_interrupt): added for
  Thread.control_intgerrupt and Thread.check_interrupt.
  See details on rdoc.
  I'll make an ticket for this feature.
* test/ruby/test_thread.rb: add a test for Thread.control_intgerrupt.
* thread.c (rb_threadptr_raise): make a new exception object
  even if argc is 0.
* thread.c (rb_thread_kill): kill thread immediately if target thread
  is current thread.
* vm_core.h (RUBY_VM_CHECK_INTS_BLOCKING): added.
  CHECK_INTS while/after blocking operation.
* vm_core.h (RUBY_VM_CHECK_INTS): require rb_thread_t ptr.
* cont.c (fiber_switch): use replaced RUBY_VM_CHECK_INTS().
* eval.c (ruby_cleanup): ditto.
* insns.def: ditto.
* process.c (rb_waitpid): ditto.
* vm_eval.c (vm_call0): ditto.
* vm_insnhelper.c (vm_call_method): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36470 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-19 14:19:40 +00:00
ko1 28144433b2 * thread.c (rb_threadptr_async_errinfo_*): manage async errors queue.
Async events such as an exception throwed by Thread#raise,
  Thread#kill and thread termination (after main thread termination)
  will be queued to th->async_errinfo_queue.
  - clear: clear the queue.
  - enque: enque err object into queue.
  - deque: deque err object from queue.
  - active_p: return 1 if the queue should be checked.
  rb_thread_t#thrown_errinfo was removed.
* vm_core.h: add declarations of rb_threadptr_async_errinfo_*.
  remove rb_thread_t#thrown_errinfo field and
  add rb_thread_t#async_errinfo_queue (queue body: Array),
  rb_thread_t#async_errinfo_queue_checked (flag),
  rb_thread_t#async_errinfo_mask_stack(Array, not used yet).
* vm.c (rb_thread_mark): fix a mark function.
* cont.c (rb_fiber_start): enque an error.
* process.c (after_fork): clear async errinfo queue.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36430 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-18 05:46:40 +00:00
nobu 7bca2f031a get rid of warnings
* io.c (sysopen_func, rb_sysopen_internal): cast through VALUE to get
  rid of warnings.  fixup of r36355.
* process.c (rb_waitpid_blocking, rb_waitpid): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36361 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-11 03:17:35 +00:00
nobu c51a826764 rb_thread_call_without_gvl
* include/ruby/thread.h: new header file for thread stuff.
* thread.c (rb_thread_call_without_gvl): export.  [Feature#4328]
  returns void* instead of VALUE.  [Feature #5543]
* thread.c (rb_thread_blocking_region): deprecate.  [ruby-core:46295]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36355 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-10 13:57:11 +00:00
kosaki 3e1d8aab17 * dln.c: Simplify and make consistent an ifdef for Mac OS X.
* ext/socket/rubysocket.h: ditto.
* ext/tk/stubs.c: ditto.
* io.c: ditto.
* process.c: ditto.
* signal.c: ditto.
* vm_dump.c: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36346 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-09 15:52:49 +00:00
akr f559d61607 update doc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36245 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-28 10:38:26 +00:00
nobu f4d2374b45 adjust style.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36232 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-27 05:37:15 +00:00
nobu 2240eb37b8 popen: shell commands with envvars and execopts
* io.c (is_popen_fork): check if fork and raise NotImplementedError if
  unavailable.
* io.c (rb_io_s_popen): allow environment variables hash and exec
  options as flat parameters, not in an array arguments.
  [Feature#6651] [EXPERIMENTAL]
* process.c (rb_execarg_extract_options): extract exec options, but no
  exceptions on non-exec options and returns them as a Hash.
* process.c (rb_execarg_setenv): set environment variables.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36229 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-27 00:15:51 +00:00
nobu ffa20cf154 use rb_check_hash_type
* class.c (rb_scan_args): use rb_check_hash_type.
* process.c (rb_exec_getargs): ditto.
* sprintf.c (get_hash): ditto.
* string.c (rb_str_sub_bang, str_gsub): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36220 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-26 07:46:24 +00:00
nobu 5be0ab591c process.c: separate check_exec_fds_1
* process.c (check_exec_fds): separate check_exec_fds_1() since
  nonstatic initializer of an aggregate type is not allowed by C89.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36208 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-24 13:53:44 +00:00
akr 78993d43c7 update async-signal-safe comments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36206 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-24 13:35:56 +00:00
akr 72bbf9822d * internal.h (rb_execarg): options field removed.
* process.c: follow the rb_execarg change.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36204 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-23 22:48:11 +00:00
akr 1ad4751aac * process.c (proc_spawn_cmd): unused variable removed to suppress a
warning.
  (save_env): ditto.

  [ruby-core:45797] reported by Luis Lavena.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36203 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-23 14:50:38 +00:00
akr f1734b4287 * internal.h (rb_execarg): add new_pgroup_given and new_pgroup_flag
fields.

* process.c (EXEC_OPTION_NEW_PGROUP): removed.
  (proc_spawn_cmd): take a struct rb_execarg argument.
  use the new fields.
  (rb_execarg_addopt): use the new fields.
  (rb_spawn_process): follow the proc_spawn_cmd change.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36202 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-23 14:21:47 +00:00
akr 345ecf3711 * internal.h (rb_execarg): add fd_dup2, fd_close, fd_open,
fd_dup2_child fields.

* process.c (EXEC_OPTION_DUP2): removed.
  (EXEC_OPTION_CLOSE): removed.
  (EXEC_OPTION_OPEN): removed.
  (EXEC_OPTION_DUP2_CHILD): removed.
  (mark_exec_arg): mark the new fields.
  (check_exec_redirect1): change condition for default option.
  (check_exec_redirect): take a struct rb_execarg argument.
  use the new fields.
  (rb_execarg_addopt): follow the check_exec_redirect change.
  (check_exec_fds): use the new fields.
  (save_redirect_fd): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36201 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-23 11:35:32 +00:00
akr fe688f2d30 * process.c (rb_execarg_fixup): fix envopts condition.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36200 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-23 10:01:46 +00:00
akr 759c214a33 * process.c (check_exec_redirect1): extracted from
check_exec_redirect.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36199 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-23 09:44:43 +00:00
akr 92af9dddc8 * process.c (save_env): don't use EXEC_OPTION_UNSETENV_OTHERS.
(rb_execarg_run_options): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36198 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-23 08:22:53 +00:00
akr 26ecb6cbc4 * internal.h (rb_execarg): add env_modification field.
* process.c (EXEC_OPTION_ENV): removed.
  (mark_exec_arg): mark env_modification field.
  (rb_exec_fillarg): update the new field, instead of options array.
  (rb_execarg_fixup): use the new field.
  (save_env): ditto.
  (rb_execarg_run_options): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36197 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-23 08:18:34 +00:00
akr f732c5046e * internal.h (rb_execarg): add rlimit_limits field.
* process.c (EXEC_OPTION_RLIMIT): removed.
  (mark_exec_arg): mark rlimit_limits field.
  (rb_execarg_addopt): update the new fields, instead of options array.
  (run_exec_rlimit): use the new field.
  (rb_execarg_run_options): clear sarg using MEMZERO.  use the new
  field.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36196 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-23 07:30:26 +00:00
akr b25b9569e5 * internal.h (rb_execarg): add chdir_given and chdir_dir fields.
* process.c (EXEC_OPTION_CHDIR): removed.
  (mark_exec_arg): mark chdir_dir field.
  (rb_execarg_addopt): update the new fields, instead of options array.
  (rb_execarg_run_options): use the new fields.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-23 06:23:35 +00:00
akr f527ad625d * internal.h (rb_execarg): add close_others_given, close_others_do and
close_others_maxhint fields.

* process.c (EXEC_OPTION_CLOSE_OTHERS): removed.
  (rb_execarg_addopt): update the new fields, instead of options array.
  (check_exec_fds): take eargp as an argument.  update the
  close_others_maxhint field.
  (rb_execarg_fixup): follow the argument change of check_exec_fds.
  (rb_execarg_run_options): use the new fields.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36194 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-23 04:23:03 +00:00
akr 40ae2e0108 * internal.h (rb_execarg): add unsetenv_others_given and
unsetenv_others_do fields.

* process.c (EXEC_OPTION_UNSETENV_OTHERS): removed.
  (rb_execarg_addopt): update the new fields, instead of options array.
  (rb_execarg_fixup): use the new fields.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36193 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-23 01:43:51 +00:00
akr 2a15a26c57 * process.c: use the variable name "soptions" for sargp->options.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36192 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-23 00:36:42 +00:00
akr 5c25fad66d * process.c: use the name "sargp" for struct rb_execarg variables
consistently for saving process attributes. 

* io.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36191 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-23 00:18:32 +00:00
akr 3eafc1660f * process.c: use the name "eargp" for struct rb_execarg variables
consistently except for saving process attributes. 

* io.c: ditto.

* ext/pty/pty.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36189 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-22 23:09:16 +00:00
akr bcadfd9c08 * internal.h (rb_execarg): add pgroup_given and pgroup_pgid fields.
* process.c (EXEC_OPTION_PGROUP): removed.
  (rb_execarg_addopt): update the new fields, instead of options array.
  (run_exec_pgroup): take a struct rb_execarg argument.  refer the new
  fields.
  (rb_execarg_run_options): follow run_exec_pgroup change.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36181 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-22 11:30:29 +00:00
akr 471d8d2586 * process.c: pass struct rb_execarg value instead of its options
field for saving process attribute changing functions.
  (save_redirect_fd): take a struct rb_execarg argument.
  (run_exec_dup2): ditto.
  (run_exec_close): ditto.
  (run_exec_open): ditto.
  (run_exec_dup2_child): ditto.
  (run_exec_pgroup): ditto.
  (run_exec_rlimit): ditto.
  (save_env): ditto.
  (rb_execarg_run_options): follow the above functions change.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36178 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-22 09:24:21 +00:00
nobu 47c6131b29 process.c: constant expression
* process.c (rb_exec_async_signal_safe): use a constant expression
  instead of a macro.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36173 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-22 03:07:26 +00:00
akr ed8040a62b * process.c (rb_execarg_addopt): take a VALUE argument instead of
struct rb_execarg.
  (rb_exec_arg_addopt): follow the rb_execarg_addopt change.
  (check_exec_options_i): ditto.

* io.c (pipe_open): follow the rb_execarg_addopt change.

* internal.h (rb_execarg_addopt): follow the definition change.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36167 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-21 12:18:40 +00:00
akr 511e25b2d5 * process.c (rb_exec_fillarg): take a VALUE argument instead of
struct rb_execarg.
  (rb_check_exec_options): ditto.
  (check_exec_options_i): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36166 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-21 11:36:25 +00:00
akr 1b2c2316a5 * process.c (rb_exec_async_signal_safe): use rb_execarg_run_options
instead of rb_run_exec_options_err.
  (rb_spawn_process): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36165 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-21 10:48:48 +00:00
akr 0a431f6903 * process.c (rb_exec_fillarg): take a VALUE argument instead of
struct rb_execarg.
  (rb_execarg_init): follow the rb_exec_fillarg change.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36164 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-21 10:03:23 +00:00
akr 46e23dc03d * process.c (rb_execarg_init): take a VALUE argument instead of
struct rb_execarg.
  (rb_execarg_new): follow the rb_execarg_init change.
  (rb_exec_arg_init): ditto.

* internal.h (rb_execarg_init): follow the definition change.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36162 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-21 09:39:10 +00:00
nobu b8b67c0b9d process.c: fix type
* process.c (rb_spawn_internal): fix type of a local variable.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36160 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-21 05:08:24 +00:00
akr d73d3a743b * process.c (rb_execarg_fixup): take a VALUE argument instead of
struct rb_execarg.

* internal.h (rb_execarg_fixup): follow the definition change.

* io.c (pipe_open): follow rb_execarg_fixup change.

* ext/pty/pty.c (establishShell): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36157 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-20 21:25:20 +00:00
akr 5309af971d * internal.h (struct rb_execarg): add umask_given and umask_mask
fields.

* process.c (STATIC_ASSERT): removed.
  (rb_execarg_addopt): follow the rb_execarg change.
  (rb_execarg_run_options): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36154 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-20 12:27:09 +00:00
akr b60713de73 * internal.h (struct rb_execarg) moved and renamed from
struct rb_exec_arg in intern.h.

* include/ruby/intern.h (struct rb_exec_arg): refer Data object which
  contains struct rb_execarg.

* process.c: use struct rb_execarg instead of struct rb_exec_arg
  except functions declared in intern.h.
  (rb_exec_arg_addopt): extract a pointer to struct rb_execarg from
  struct rb_exec_arg.
  (rb_exec_arg_init): ditto.
  (rb_exec_arg_fixup): ditto.
  (rb_run_exec_options_err): ditto.
  (rb_run_exec_options): ditto.
  (rb_exec_err): ditto.
  (rb_exec): ditto.

* io.c: use struct rb_execarg instead of struct rb_exec_arg.

* ext/pty/pty.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36153 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-20 11:46:50 +00:00
akr 826f98e688 * internal.h (rb_execarg_new): declared.
(rb_execarg_get): ditto.

* process.c (mark_exec_arg): new function.
  (free_exec_arg): ditto.
  (memsize_exec_arg): ditto.
  (exec_arg_data_type): defined.
  (rb_execarg_new): new function.
  (rb_execarg_get): ditto.
  (rb_f_exec): use rb_execarg_new.
  (rb_spawn_internal): ditto.
  (rb_f_spawn): ditto.

* io.c (pipe_open_v): use rb_execarg_new.
  (pipe_open_s): ditto.

* ext/pty/pty.c (establishShell): use rb_execarg_new.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36152 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-20 10:31:02 +00:00
nobu 5a24475a13 process.c: fixnum umask
* process.c (rb_execarg_addopt): always make Fixnum, and ignore higher
  bits in too large umask value.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36148 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-20 02:33:06 +00:00
akr a60fe909d7 fix async-signal-safe comments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36135 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-19 09:14:18 +00:00
nobu 52b497d8b7 process.c: no method calls in async-signal-safe
* process.c (rb_execarg_run_options): do not call any methods in the
  async-signal-safe function.  mask has been checked with NUM2MODET()
  already and converted with LONG2NUM().


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36134 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-19 08:51:57 +00:00
akr ea325fcd67 * process.c (proc_exec_sh): don't strip leading spaces of the script.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36085 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-14 13:11:41 +00:00
akr b41bc68688 update doc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36073 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-13 20:55:40 +00:00
akr d793a86b43 update doc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36062 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-13 11:37:33 +00:00
akr e9a1ba232a * process.c (rb_fork_internal): move a variable declaration.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36061 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-13 11:20:33 +00:00
nobu 9c48976392 process.c: suppress warning
* process.c (compare_posix_sh): not used on Win32.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36057 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-13 07:38:06 +00:00
nobu 621153bf3f process.c: no SIZE_T_MAX
* process.c (rb_exec_fillarg): get rid of SIZE_T_MAX which may need
  more headers.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36051 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-13 01:20:29 +00:00
nobu 33b15cef6c process.c: fix array element size
* process.c (rb_exec_fillarg): fix array element size.  "continue" and
  "readonly" exceeded the size.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36050 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-13 01:20:05 +00:00
nobu 2d460925f2 process.c: use shell for reserved or special built-in
* process.c (rb_exec_fillarg): use shell if the first word is reserved
  or special built-in name.
  http://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36049 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-13 00:56:31 +00:00
nobu e6a6561121 process.c: treat '=' only in the first word
* process.c (rb_exec_fillarg): treat '=' only in the first word.  if
  the first word does not contain '=', it is the command name and
  environment assignments cannot be anymore.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36048 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-13 00:55:31 +00:00
nobu 18c32c9451 process.c: constified
* process.c (rb_exec_fillarg): constified.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36046 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-13 00:54:32 +00:00
ngoto 3f4b0e17f4 * process.c (rb_exec_arg_fixup): fix compile error
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36044 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-12 13:55:42 +00:00
akr 640e0a33b7 * process.c (rb_exec_fillarg): treat '=' character as an meta
character to detect assignments preceding command name.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36041 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-12 12:41:08 +00:00
akr 37a1355bf8 * include/ruby/intern.h (rb_exec_arg_init): deprecated.
(rb_exec_arg_addopt): ditto.
  (rb_exec_arg_fixup): ditto.
  (rb_run_exec_options): ditto.
  (rb_run_exec_options_err): ditto.

* internal.h (rb_execarg_init): declared.
  (rb_execarg_addopt): ditto.
  (rb_execarg_fixup): ditto.
  (rb_execarg_run_options): ditto.

* process.c: call rb_execarg_addopt, rb_execarg_fixup,
  rb_execarg_run_options, rb_execarg_init.
  (rb_execarg_addopt): renamed from rb_exec_arg_addopt.
  (rb_exec_arg_addopt): stub to call rb_execarg_addopt.
  (rb_execarg_init): renamed from rb_exec_arg_init.
  (rb_exec_arg_init): stub to call rb_execarg_init.
  (rb_execarg_fixup): renamed from rb_exec_arg_fixup.
  (rb_exec_arg_fixup): stub to call rb_execarg_fixup.
  (rb_execarg_run_options): renamed from rb_run_exec_options_err.
  (rb_run_exec_options_err): stub to call rb_execarg_run_options.
  (rb_run_exec_options): call rb_execarg_run_options.

* io.c: call rb_execarg_addopt, rb_execarg_fixup,
  rb_execarg_run_options, rb_execarg_init.

* ext/pty/pty.c (establishShell): call rb_execarg_init and
  rb_execarg_fixup.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36039 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-12 11:34:51 +00:00
akr 45e5f2f690 * process.c (rb_exec_fillarg): detect '#' as a meta character.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36036 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-11 21:40:50 +00:00
akr ffe89b7621 add comment about meta characters.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36033 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-11 12:37:55 +00:00
akr 9ea35ccf30 * process.c (rb_proc_exec_n): revert the function removed at r35889.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36028 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-10 21:31:49 +00:00
akr fa5cd00340 * process.c (rb_exec_without_timer_thread): renamed from rb_exec_err.
(rb_exec_err): new stub function to call
  rb_exec_without_timer_thread.
  (rb_f_exec): call rb_exec_without_timer_thread.
  (rb_exec): call rb_exec_without_timer_thread.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36021 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-10 12:31:40 +00:00
akr 4fa66dc53b * process.c (rb_fork): call rb_fork_internal instead of rb_fork_err.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36020 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-10 12:13:33 +00:00
akr f589733a02 * process.c (rb_fork_ruby): call rb_fork_internal directly.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36019 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-10 11:56:20 +00:00
akr 4b70fab915 * process.c (rb_fork_ruby): new function.
(rb_f_fork): use rb_fork_ruby instead of rb_fork.
  (rb_daemon): ditto.

* io.c (pipe_open): use rb_fork_ruby instead of rb_fork.

* internal.h (rb_fork_ruby): declared.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36018 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-10 11:21:07 +00:00
akr 8fdd48d69f * process.c (retry_fork): call after_fork except in a child process.
(rb_fork_internal): restrict after_fork call condition.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36012 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-10 06:51:05 +00:00
akr c39fd4c340 * process.c (rb_f_exec): call rb_exec_async_signal_safe except on
Mac OS X.  cf. the comment in before_exec_non_async_signal_safe.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36009 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-10 03:46:09 +00:00
akr 258716bd9d * process.c (rb_fork_internal): call after_fork only unless
chfunc_is_async_signal_safe.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36007 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-10 02:45:38 +00:00
akr 839dc7d409 update async-signal-safe comments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36004 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-10 01:46:45 +00:00
akr 18088467e7 * process.c (rb_exec_async_signal_safe): exported.
* ext/pty/extconf.rb: modify $INCFLAGS to include internal.h

* ext/pty/pty.c: include internal.h.
  (chfunc): don't call rb_thread_atfork_before_exec.  use
  rb_exec_async_signal_safe instead of rb_f_exec.
  (establishShell): set up earg.  use rb_fork_async_signal_safe
  instead of rb_fork_err.

* internal.h (rb_exec_async_signal_safe): declared.
  (rb_fork_async_signal_safe): declared.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36002 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-10 01:29:58 +00:00
akr 8fcdb757a5 * process.c (rb_f_exec): use rb_exec_arg_prepare.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36000 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-10 01:17:53 +00:00
akr 99c71b1ee4 * process.c: split after_exec into async-signal-safe part and rest.
(after_exec_async_signal_safe): extracted from after_exec.
  (after_exec_non_async_signal_safe): ditto.
  (after_exec): call them.
  (rb_exec_async_signal_safe): call after_exec_async_signal_safe.
  (rb_exec_err): call after_exec_non_async_signal_safe instead of
  after_exec.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35999 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-09 21:48:42 +00:00
akr f45eb45100 * process.c (rb_fork_internal): initialize exc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35993 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-09 16:37:44 +00:00
akr b11046a61e * process.c: don't use non async-signal-safe functions in a child
process before exec, for invoking a command.
  (rb_exec_atfork): call rb_exec_async_signal_safe only.
  (retry_fork): take chfunc_is_async_signal_safe argument.  call
  before_fork and after_fork only unless chfunc_is_async_signal_safe.
  (send_child_error): take chfunc_is_async_signal_safe argument.
  send an exception only unless chfunc_is_async_signal_safe.
  (recv_child_error): take chfunc_is_async_signal_safe argument.
  receive an exception only unless chfunc_is_async_signal_safe.
  (rb_fork_internal): renamed from rb_fork_err and take
  chfunc_is_async_signal_safe argument.
  use rb_protect only unless chfunc_is_async_signal_safe.
  (rb_fork_err): call rb_fork_internal with false as
  chfunc_is_async_signal_safe.
  (rb_fork_async_signal_safe): call rb_fork_internal with true as
  chfunc_is_async_signal_safe.
  (rb_spawn_process): call rb_fork_async_signal_safe instead of
  rb_fork_err.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35991 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-09 15:25:34 +00:00
akr 14ec2c802d * process.c (rb_fork_err): rewrite a complex "if" statement.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35990 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-09 14:58:03 +00:00
akr d074d0df95 * process.c (before_exec_async_signal_safe): extracted from
before_exec.
  (before_exec_non_async_signal_safe): ditto.
  (before_exec): call before_exec_async_signal_safe and
  before_exec_non_async_signal_safe.
  (rb_exec_async_signal_safe): call before_exec_async_signal_safe.
  (rb_exec_err): call before_exec_non_async_signal_safe instead of
  before_exec.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35989 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-09 14:45:46 +00:00
akr 7057facef3 * process.c (retry_fork): rewrite a complex "for" statement by
simple statements. 


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35986 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-09 13:28:02 +00:00
akr 1ad3f4b05d * process.c (retry_fork): extracted from rb_fork_err.
(send_child_error): ditto.
  (recv_child_error): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35985 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-09 12:51:01 +00:00
akr a46bf824bf update async-signal-safe comments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35983 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-09 02:09:10 +00:00
akr d410a38b8e * process.c (rb_exec_async_signal_safe): extracted from rb_exec_err.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35982 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-09 01:57:46 +00:00
akr 4da82e58a1 update async-signal-safe comments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35981 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-09 01:40:22 +00:00
akr 4a9a7756da * process.c: simplified because close_others option is always
enabled by default.
  (rb_f_exec): don't need to set the option.
  (rb_exec_arg_prepare): don't need to set the option.  don't need
  default_close_others argument.
  (rb_spawn_internal): don't need to give default_close_others
  argument for rb_exec_arg_prepare.  don't need default_close_others
  argument.
  (rb_spawn_err): don't need to give default_close_others
  argument for rb_spawn_internal.
  (rb_spawn): don't need to give default_close_others
  argument for rb_spawn_internal.
  (rb_f_system): don't need to give default_close_others argument for
  rb_spawn_internal. 
  (rb_f_spawn): don't need to give default_close_others argument for
  rb_exec_arg_prepare. 



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35980 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-09 01:07:07 +00:00
akr 0ec4ae7c8e * process.c (rb_proc_exec): call before_exec() here addition to
rb_exec_err.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-09 00:01:58 +00:00
nobu 1102fd2f3e * remove trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35972 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-08 22:44:01 +00:00
akr 2fb032b74b * process.c (rb_exec_err): before_exec() call moved from proc_exec_cmd
and proc_exec_sh.
  (rb_proc_exec): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35969 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-08 16:26:01 +00:00
akr b9824fbb08 * include/ruby/intern.h (rb_exec_arg_init): declaration changed to
return a value.

* process.c (rb_exec_arg_init): return a value.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35967 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-08 16:13:26 +00:00
akr 795c5f9b40 * process.c: don't check the availability of FD_CLOEXEC. It should
be available if fork() is available.

* io.c: ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35966 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-08 14:46:23 +00:00
akr ba1c1786d6 add comments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35965 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-08 13:50:38 +00:00
akr 373a7d1a95 * process.c (rb_fork_err): revert r35955. The condition needs !chfunc
to close ep[0] and ep[1].  The catched exception is re-raised
  immediately after that if status is not NULL.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35964 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-08 13:43:48 +00:00
akr c17c8ebb14 * process.c (rb_exec_err): after_exec() call moved from proc_exec_cmd and
proc_exec_sh.
  (rb_proc_exec): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35963 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-08 10:57:10 +00:00
akr 86c82ad647 * process.c (ARGV_COUNT): unused macro removed.
(ARGV_SIZE): ditto.
  (ALLOC_ARGV): ditto.
  (ALLOC_ARGV_WITH_STR): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35962 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-08 10:02:00 +00:00
nobu 52c7036436 process.c: child process error state
* process.c (rb_fork_err): error state in the child process is prior
  to exceptions in proc_syswait().


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35960 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-08 03:04:42 +00:00
nobu 182dc9d40d process.c, ext/pty/pty.c: status on errors
* process.c (rb_fork_err): determine status on errors.
* ext/pty/pty.c (establishShell): reraise exception if something
  raised during sleep.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35959 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-08 02:26:39 +00:00
akr 0d92aac602 * process.c (rb_fork_err): Fix the conditoin to use rb_protect.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35955 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-07 13:13:52 +00:00
akr 7e0c93b0c3 fix a comment.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35950 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-06 13:10:54 +00:00
akr 7f83b7e14f remove wrong comments.
earg is processed by surrounding rb_run_exec_options_err call.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35949 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-06 12:34:51 +00:00
akr 3c3b563205 * process.c (proc_exec_cmd) renamed from proc_exec_v.
(proc_exec_sh): renamed from rb_proc_exec_e.
  (proc_spawn_cmd_internal): renamed from proc_spawn_v.
  (proc_spawn_cmd): renamed from proc_spawn_n.
  (proc_spawn_sh): renamed from proc_spawn.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35948 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-06 12:33:28 +00:00
usa ee011f7b1f * process.c (try_with_sh): please take care of the macro defined by
you.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35947 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-06 12:20:58 +00:00
akr aaf6bde978 update async-signal-safe comments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35945 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-06 11:58:09 +00:00
akr 70232e400c * process.c (proc_exec_v): don't call dln_find_exe_r here because it
is not async-signal-safe and proc_exec_v is called in a child
  process.
  command_abspath field of rb_exec_arg.
  (rb_exec_fillarg): call dln_find_exe_r and set command_abspath.
  (rb_exec_err): Give the absolute path of the invoking command for
  proc_exec_v, instead of the command name.

* internal.h: add command_abspath field for rb_exec_arg. 



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35944 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-06 11:49:30 +00:00
akr 7685837427 * process.c (try_with_sh): take envp argument.
(exec_with_sh): ditto.  use it for execve.
  (proc_exec_v): provide envp for try_with_sh.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35943 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-06 11:09:26 +00:00
usa 494d01410f * process.c (rb_run_exec_options_err): allocate a temporary buffer for
run_exec_dup2() for restoring fds on non-fork environments.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35935 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-06 03:39:40 +00:00
akr a4ef2bbdd1 * process.c (rb_exec_fillarg): check use_shell field before accessing
a union field.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35933 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-05 20:29:15 +00:00
akr c8d6b6e8fa * process.c (rb_spawn_process): prog variable is not used for Unix.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35931 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-05 19:59:43 +00:00
akr 0acd09c9e5 update async-signal-safe comments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35930 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-05 15:31:39 +00:00
akr 3162e673a1 * internal.h (rb_exec_arg_init): change return type to void.
* process.c (rb_exec_arg_init): don't return a value.
  (rb_exec_arg_prepare): ditto.
  (rb_spawn_process): don't take the prog argument.  extract the 
  information from earg.
  (rb_spawn_internal): follow rb_spawn_process change.
  (rb_f_spawn): ditto.

* io.c (pipe_open): don't take the prog argument.  extract the
  information from eargp.
  (pipe_open_v): follow pipe_open change.
  (pipe_open_s): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35928 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-05 15:24:32 +00:00
akr 53b17a769b * internal.h (rb_exec_arg): use union to represent command invocation
with/without shell.

* process.c: follow the rb_exec_arg change.

* io.c (pipe_open): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35927 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-05 14:53:31 +00:00
akr 71e7935331 update async-signal-safe comments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35926 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-05 14:33:32 +00:00
akr ad5bfed17c * process.c (rb_exec_arg_fixup): allocate a temporary buffer for
run_exec_dup2 here because it should be async-signal-safe.
  (run_exec_dup2): use the temporary buffer.
  (run_exec_dup2_tmpbuf_size): new function.

* include/ruby/intern.h (rb_exec_arg): add dup2_tmpbuf field.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35923 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-05 12:59:40 +00:00
akr b1ae6e473e * process.c (strtok): declaration removed because it is not used.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35921 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-05 10:59:51 +00:00
akr e3d685907c * process.c (proc_spawn): don't detect simple command line here
because rb_exec_fillarg already did.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35920 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-05 10:35:47 +00:00
akr e58ec33721 * process.c (rb_exec_fillarg): bail out a loop eagerly.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35919 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-05 10:21:22 +00:00
akr 5b13036fce * process.c: add comments about async-signal-safe.
* io.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35918 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-05 10:16:11 +00:00
akr 993b4f3911 add comment.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35911 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-04 11:13:47 +00:00
akr 71fd73dff8 * process.c (rb_exec_fillarg): allocate one more element before
beginning in argv_str for try_with_sh.

* internal.h (ARGVSTR2ARGC): adjust for the above change.
  (ARGVSTR2ARGV): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35910 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-04 11:01:41 +00:00
akr 41819dc447 * internal.h (ARGVSTR2ARGC): defined.
(ARGVSTR2ARGV): defined.

* process.c (proc_exec_v): use ARGVSTR2ARGV.
  (rb_spawn_process): use ARGVSTR2ARGC and ARGVSTR2ARGV.

* io.c (pipe_open): use ARGVSTR2ARGV.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35909 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-04 10:19:32 +00:00
nobu de8eb56e88 merge definitions
* process.c (proc_exec_v, rb_proc_exec_e): merge definitions.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35906 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-04 05:46:24 +00:00
nobu b89e9bf544 unused parameter
* process.c (proc_spawn_n): remove unused parameter.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35905 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-04 05:46:22 +00:00
nobu a99d3a6271 unused variables
* io.c (pipe_open): argc and argv are not used on win32.

* process.c (rb_spawn_process): remove already useless variables.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35904 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-04 05:33:43 +00:00
usa 9bb642d65a * process.c (rb_exec_err): should preserve errno.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35903 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-04 05:06:56 +00:00
usa 2493e48d40 * process.c (rb_run_exec_options_err): restore save_env() call for
non-fork environments.

* process.c (rb_exec_err): restore environments after the failure of
  exec to fix [ruby-core:44093] [Bug #6249] on non-fork environments


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35897 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-04 02:36:11 +00:00
usa 859869e522 * io.c (pipe_open): follow up changes in r35889.
* process.c (proc_spawn_n): now uses char ** instead of VALUE *.

* process.c (rb_spawn_process): prog is now VALUE of String, not char *.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35896 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-04 01:44:27 +00:00
akr 6b348951ca * process.c (rb_spawn_process): fix for Windows. not tested.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35892 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-03 15:45:46 +00:00
akr 93e005d177 * process.c (rb_proc_exec_e): don't use ISSPACE(). \f, \r and \v
are not word separator in Bourne shell.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35890 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-03 15:13:54 +00:00
akr 9ee4575ea4 * include/ruby/intern.h (rb_exec_arg): remove argc and argv fields.
add use_shell, argv_str and argv_buf fields.

* process.c (rb_proc_exec_e): don't split shell command line arguments
  here to avoid memory allocation in a child process.
  (rb_exec_fillarg): split shell command line arguments here.
  (proc_exec_v): takes argv_str argument instead of argv.
  (rb_proc_exec_ne): removed.
  (rb_proc_exec_n): removed.
  (rb_run_exec_options_err): don't initialize the removed fields.
  (rb_exec_err): don't initialize the removed fields.
  call proc_exec_v directly instead of rb_proc_exec_ne.
  (rb_spawn_process): use use_shell field.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35889 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-03 14:53:13 +00:00
akr cb44ffc4af * process.c (rb_exec_getargs): remove rb_exec_arg argument.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35887 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-03 12:25:54 +00:00
akr 9977e1cbc7 * process.c (rb_check_argv): use rb_str_new_frozen instead of
rb_str_new4.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35885 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-03 12:18:45 +00:00
akr 033e2187c6 * process.c (rb_proc_exec_e): extended version of rb_proc_exec() to
call execle().
  (rb_proc_exec): use rb_proc_exec_e().
  (rb_exec_err): use rb_proc_exec_e().


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35884 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-03 11:12:20 +00:00
akr f4f28bf75f * use execve() to preserve environment variables when exec method is
failed.  [ruby-core:44093] [ruby-trunk - Bug #6249]

* include/ruby/intern.h (rb_exec_arg): add envp_str and envp_buf field
  to store envp of execve().

* process.c (proc_exec_v): takes envp_str as an argument and use it
  for execve().
  (rb_proc_exec_ne): extended version of rb_proc_exec_n().
  (rb_proc_exec_n): use rb_proc_exec_ne().
  (rb_proc_exec): follow proc_exec_v() change.
  (fill_envp_buf_i): new function.
  (rb_exec_arg_fixup): set up envp_str and envp_buf.
  (save_env_i): removed.
  (save_env): removed.
  (rb_run_exec_options_err): don't modify environment variables.
  (rb_exec_err): use rb_proc_exec_ne().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35882 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-03 08:29:48 +00:00
yugui 76bc2d1ed7 Imports Ruby's port to NativeClient (a.k.a NaCl).
Patch by Google Inc. [ruby-core:45073].

* configure.in (RUBY_NACL): New M4 func to configure variables for
  NaCl.
  (RUBY_NACL_CHECK_PEPPER_TYPES): New M4 func to check the old names
  of Pepper interface types.
  (BTESTRUBY): New variable to specify which ruby should be run on
  "make btest". NaCl can run the built binary by sel_ldr, but it need
  rbconfig.rb. So this variable is distinguished from $MINIRUBY.
  
* thread_pthread.c: Disabled some features on NaCl.

* io.c: ditto.

* process.c: ditto.

* signal.c: ditto.

* file.c: ditto.

* missing/flock.c: ditto.

* nacl/pepper_main.c: An example implementation of Pepper application
  that embeds Ruby.

* nacl/example.html: An example of web page that uses the Pepper
  application.

* nacl/nacl-config.rb: Detects variants of NaCl SDK.

* nacl/GNUmakefile.in: Makefile template for NaCl specific build
  process.

* nacl/package.rb: script for packaging a NaCl-Ruby embedding
  application. 

* nacl/reate_nmf.rb: Wrapper script of create_nmf.py

* dln.c (dln_load): Added a hack to call on NaCl.

* util.c (ruby_getcwd): Path to the current directort is not available
  on NaCl.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35672 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-17 02:48:59 +00:00
drbrain e95f7ea80d * variable.c (trace_ev): Removed "not reached" comment as this line is
reached.
* variable.c (rb_obj_remove_instance_variable):  Replaced "not reached"
  comment with the UNREACHABLE macro.
* variable.c (rb_mod_const_missing):  ditto.
* variable.c (rb_mod_remove_cvar):  ditto.
* enum.c (first_i):  ditto.
* string.c (rb_str_aref):  ditto.
* string.c (str_byte_aref):  ditto.
* string.c (rb_to_id):  ditto.
* io.c (rb_io_fmode_modestr):  ditto.
* io.c (rb_io_oflags_modestr):  ditto.
* pack.c (num2i32):  ditto.
* vm_eval.c (rb_method_missing):  ditto.
* vm_eval.c (rb_f_throw):  ditto.
* dir.c (dir_read):  ditto.
* win32/win32.c (child_result):  ditto.
* struct.c (rb_struct_getmember):  ditto.
* struct.c (rb_struct_set):  ditto.
* struct.c (rb_struct_aref_id):  ditto.
* eval.c (rb_f_raise):  ditto.
* process.c (rb_f_exit_bang):  ditto.
* process.c (rb_f_exit):  ditto.
* process.c (rb_f_abort):  ditto.
* ext/-test-/iter/break.c (iter_break_value):  ditto.
* ext/pty/pty.c (pty_check):  ditto.
* ext/openssl/ossl_pkey.c (ossl_pkey_new):  ditto.
* ext/readline/readline.c (rb_remove_history):  ditto.
* ext/stringio/stringio.c (strio_unimpl):  ditto.
* numeric.c (num_sadded):  ditto.
* numeric.c (num_init_copy):  ditto.
* numeric.c (rb_num2ll):  ditto.
* numeric.c (rb_num2ull):  ditto.
* vm_insnhelper.c (call_cfunc):  ditto.
* ruby.c (opt_W_getter):  ditto.
* bignum.c (rb_big_coerce):  ditto.
* file.c (rb_f_test):  ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35322 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-14 00:36:26 +00:00
drbrain da39d32f60 * encoding.c (rb_enc_codepoint_len): Use UNREACHABLE to avoid "control
reaches end of non-void function" warnings.  [ruby-trunk - Bug #6066]
* re.c (name_to_backref_number):  ditto.
* object.c (rb_Float):  ditto.
* io.c (io_readpartial):  ditto.
* io.c (io_read_nonblock):  ditto.
* pack.c (rb_uv_to_utf8):  ditto.
* proc.c (rb_method_entry_arity):  ditto.
* vm_method.c (rb_f_notimplement):  ditto.
* struct.c (rb_struct_aset_id):  ditto.
* class.c (rb_scan_args):  ditto.
* process.c (rlimit_resource_type):  ditto.
* process.c (rlimit_resource_value):  ditto.
* process.c (p_uid_switch):  ditto.
* process.c (p_gid_switch):  ditto.
* ext/digest/digest.c (rb_digest_instance_update):  ditto.
* ext/digest/digest.c (rb_digest_instance_finish):  ditto.
* ext/digest/digest.c (rb_digest_instance_reset):  ditto.
* ext/digest/digest.c (rb_digest_instance_block_length):  ditto.
* ext/bigdecimal/bigdecimal.c (BigDecimalCmp):  ditto.
* ext/dl/handle.c (rb_dlhandle_close):  ditto.
* ext/tk/tcltklib.c (pending_exception_check0):  ditto.
* ext/tk/tcltklib.c (pending_exception_check1):  ditto.
* ext/tk/tcltklib.c (ip_cancel_eval_core):  ditto.
* ext/tk/tcltklib.c (lib_get_reltype_name):  ditto.
* ext/tk/tcltklib.c (create_dummy_encoding_for_tk_core):  ditto.
* ext/tk/tkutil/tkutil.c (tk_hash_kv):  ditto.
* ext/openssl/ossl_ssl.c (ossl_ssl_session_reused):  ditto.
* ext/openssl/ossl_pkey_ec.c (ossl_ec_key_dsa_verify_asn1):  ditto.
* ext/openssl/ossl_pkey_ec.c (ossl_ec_point_is_at_infinit):  ditto.
* ext/openssl/ossl_pkey_ec.c (ossl_ec_point_is_on_curve):  ditto.
* ext/fiddle/conversions.c (generic_to_value):  ditto.
* ext/socket/raddrinfo.c (rsock_io_socket_addrinfo):  ditto.
* ext/socket/socket.c (sock_s_getnameinfo):  ditto.
* ext/ripper/eventids2.c (ripper_token2eventid):  ditto.
* cont.c (return_fiber):  ditto.
* dmydln.c (dln_load):  ditto.
* vm_insnhelper.c (vm_search_normal_superclass):  ditto.
* bignum.c (big_fdiv):  ditto.
* marshal.c (r_symlink):  ditto.
* marshal.c (r_symbol):  ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35321 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-13 23:45:37 +00:00
shirosaki 42109a02f0 * include/ruby/win32.h (rb_w32_aspawn_flags): add the declaration of
new function.

* process.c (enum): add EXEC_OPTION_PGROUP and move the position
  above for the usage in proc_spawn_n().

* process.c (proc_spawn_n): add an argument to pass new option
  `new_pgroup`. The option specifies CREATE_NEW_PROCESS_GROUP flag to
  CreateProcessW(). This flag is necessary for the usage of
  Process.kill on the subprocess on Windows.

* process.c (rb_exec_arg_addopt): ditto.

* process.c (rb_spawn_process): ditto.

* process.c (documentation for rb_f_spawn): add documentation for new
  option `new_pgroup` of spawn.

* test/ruby/test_process.rb (TestProcess#test_execopts_new_pgroup):
  add tests for option `new_pgroup`.

* test/ruby/test_thread.rb
  (TestThreadGroup#test_thread_timer_and_interrupt):
  add option `new_pgroup: true` to spawn on Windows. It's needed for
  Process.kill on a subprocess.

* win32/win32.c (CreateChild): add an argument to pass
  dwCreationFlags of CreateProcessW().

* win32/win32.c (rb_w32_spawn): ditto.

* win32/win32.c (rb_w32_aspawn_flags): add new function to pass
  dwCreationFlags.

* win32/win32.c (rb_w32_aspawn): refactor to move the content to
  rb_w32_aspawn_flags().
  [ruby-core:43245][Bug #6131]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35250 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-07 14:10:30 +00:00
nobu ca512bdaa8 * process.c (setreuid, setregid): suppress warnings.
[ruby-core:43374][Bug #6169]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35221 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-03 09:33:40 +00:00
nobu 9bf9b3ef95 * process.c (obj2uid, obj2gid): allow strings as input user/group id.
[ruby-core:40923][Feature #5610]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35158 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-28 07:40:02 +00:00
nobu b95b56cc3a * process.c: no cuddle up else's.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-28 01:28:51 +00:00
marcandre 7316302483 * include/ruby/intern.h: Add rb_check_arity, rb_error_arity [#6085]
* array.c: Use rb_check_arity / rb_error_arity

* class.c: ditto

* enumerator.c: ditto

* eval.c: ditto

* file.c: ditto

* hash.c: ditto

* numeric.c: ditto

* proc.c: ditto

* process.c: ditto

* random.c: ditto

* re.c: ditto

* signal.c: ditto

* string.c: ditto

* struct.c: ditto

* transcode.c: ditto

* vm_eval.c: ditto

* vm_insnhelper.c: ditto & implementation of rb_error_arity

* test/ruby/test_arity.rb: tests for above

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35024 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-14 21:10:34 +00:00
akr 61c148723d * process.c (rb_run_exec_options_err): chdir at last to interpret
relative pathnames from the current directory of the parent process.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34892 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-03 13:53:53 +00:00
nobu 80429eed63 * io.c, process.c, time.c, ext: use rb_sys_fail_str instead of
rb_sys_fail.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34825 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-27 01:50:27 +00:00
drbrain 9d7573c41a * process.c (proc_wait): Change typo "SystemError" to
"SystemCallError".  [ruby-trunk - Bug #5962]
* process.c (proc_wait2):  ditto


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34587 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-13 21:24:01 +00:00
naruse 88b16cebc8 * gc.c (rb_objspace_free): global_List is allocated with xmalloc.
patched by Sokolov Yura.  https://github.com/ruby/ruby/pull/78

* dln_find.c: remove useless replacement of free.

* ext/readline/readline.c (readline_attempted_completion_function):
  strings for readline must allocated with malloc.

* process.c (run_exec_dup2): use free; see also r20950.

* re.c (onig_new_with_source): use malloc for oniguruma.

* vm.c (ruby_vm_destruct): use free for VMs.

* vm.c (thread_free): use free for threads.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34238 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-01-08 21:02:08 +00:00
ayumin 9ecd19a7f8 * process.c: Fix typo. patch from Aviv Ben-Yosef.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34197 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-01-03 06:53:49 +00:00
nobu fefba781bc * process.c (rb_exit_status_code): extract from rb_f_exit_bang and
rb_f_exit.  assume 0 to be success in Kernel#exit! too.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34005 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-11 01:34:42 +00:00
nobu 8bce84fe5d * process.c (proc_seteuid_m): fix argument.
* test/ruby/test_process.rb (test_geteuid): fix typo.
* test/ruby/test_process.rb (test_getegid, test_set[eg]uid): add.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33953 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-05 10:02:02 +00:00
nobu b526738c3b * bignum.c (big_rshift), compile.c (validate_label,
iseq_build_from_ary_exception), cont.c (cont_capture), dir.c
  (dir_open_dir), gc.c (objspace_each_objects), io.c (pipe_open)
  (rb_io_advise), parse.y (parser_compile_string)
  (rb_parser_compile_file), proc.c (binding_free), process.c
  (rb_proc_exec_n, rb_seteuid_core, proc_setegid, rb_setegid_core)
  (p_uid_exchange, p_gid_exchange), regparse.c (strdup_with_null),
  signal.c (sig_dfl), vm.c (rb_iseq_eval, rb_iseq_eval_main),
  vm_insnhelper.c (vm_expandarray): suppress
  unused-but-set-variable warnings.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33951 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-05 09:57:00 +00:00
nobu 6cedbce87d * process.c (proc_seteuid): separate an internal wrapper function
from the method implementation.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33707 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-11 09:42:02 +00:00
naruse f926980902 * io.c (nogvl_io_cntl): rb_cloexec_fcntl_dupfd's 2nd argument is int.
* process.c (move_fds_to_avoid_crash): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33602 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-01 05:56:51 +00:00
akr 5c19f07700 * include/ruby/intern.h (rb_cloexec_fcntl_dupfd): declared.
* io.c (rb_cloexec_fcntl_dupfd): new function.
  (nogvl_io_cntl): use rb_cloexec_fcntl_dupfd.

* process.c (move_fds_to_avoid_crash): use rb_cloexec_fcntl_dupfd.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33575 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-30 15:17:27 +00:00
akr da74bc7552 * process.c (ruby_setsid): use rb_cloexec_open.
(rb_daemon): ditto.

* ruby.c (load_file_internal): ditto.

* file.c (rb_file_s_truncate): ditto.
  (file_load_ok): ditto.

* random.c (fill_random_seed): ditto.

* ext/pty/pty.c (chfunc): ditto.
  (get_device_once): ditto.

* ext/io/console/console.c (console_dev): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33550 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-29 04:01:54 +00:00
akr b574a4d4a1 * include/ruby/intern.h (rb_fd_set_cloexec): declared.
* io.c (rb_fd_set_cloexec): new function.
  (ruby_dup): call rb_fd_set_cloexec to set close-on-exec flag.
  (rb_sysopen_internal): ditto.
  (rb_pipe): ditto.
  (io_reopen): ditto.
  (io_cntl): ditto.

* process.c (rb_f_exec): change the default :close_others option to
  true.
  (rb_f_system): ditto.
  (move_fds_to_avoid_crash): call rb_fd_set_cloexec to set
  close-on-exec flag.
  (ruby_setsid): ditto.
  (rb_daemon): ditto.

* thread_pthread.c (rb_thread_create_timer_thread): call
  rb_fd_set_cloexec to set close-on-exec flag.

* ruby.c (load_file_internal): ditto.

* file.c (rb_file_s_truncate): ditto.
  (file_load_ok): ditto.

* random.c (fill_random_seed): ditto.

* ext/pty/pty.c (chfunc): ditto.
  (get_device_once): ditto.

* ext/openssl/ossl_bio.c (ossl_obj2bio): ditto.

* ext/socket/init.c (rsock_socket): ditto.
  (rsock_s_accept_nonblock): ditto.
  (rsock_s_accept): ditto.

* ext/socket/socket.c (rsock_sock_s_socketpair): ditto.

* ext/socket/ancdata.c (discard_cmsg): ditto.
  (make_io_for_unix_rights): ditto.

* ext/socket/unixsocket.c (unix_recv_io): ditto.

* ext/io/console/console.c (console_dev): ditto.

[ruby-core:38140] [Feature #5041]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33507 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-22 09:58:15 +00:00
nobu 8e6e8e6288 * use RB_TYPE_P which is optimized for constant types, instead of
comparison with TYPE.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33357 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-29 11:07:45 +00:00
nobu e9930a4b56 * process.c (proc_spawn_v, proc_spawn): should not wait the
spawned process.
* process.c (proc_spawn_v): fix missing argument, and try with
  /bin/sh only if failed with ENOEXEC.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33009 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-08-19 05:25:52 +00:00
akr b41ccc4a9c * include/ruby/intern.h (rb_update_max_fd): declaration moved from
internal.h.

* file.c: ditto.

* io.c: call rb_update_max_fd for each new fds.

* process.c: ditto.

* random.c: ditto.

* ruby.c: ditto.

* ext/io/console/console.c: ditto.

* ext/openssl/ossl_bio.c: ditto.

* ext/pty/pty.c: ditto.

* ext/socket/init.c: ditto.

* ext/socket/socket.c: ditto.

* ext/socket/ancdata.c: ditto.

* ext/socket/unixsocket.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32587 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-20 13:26:10 +00:00
kosaki abf99e80bf * process.c: removed signal() macro. It's no longer used.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-11 06:56:06 +00:00
kosaki 74b339e938 * thread_pthread.c (rb_thread_create_timer_thread): removed
rb_disable_interrupt()/rb_enable_interrupt().
* vm_core.h: ditto.
* process.c (static void before_exec): ditto.
* process.c (static void after_exec): ditto.
  [Bug #4765] [ruby-dev:43571]

* eval_intern.h: removed rb_trap_restore_mask().
* vm_eval.c (rb_throw_obj): ditto.
* eval.c (setup_exception): ditto.

* signal.c: removed trap_last_mask.
* signal.c (trap_restore_mask): removed.
* signal.c (init_sigchld): comment clarification why signal block
  is needed. and removed trap_last_mask operation.
* signal.c (trap_ensure): removed trap_last_mask operation.

* signal.c (rb_disable_interrupt, rb_enable_interrupt): made
  static and removed sigdelset(SIGVTALARM) and sigdelset(SIGSEGV).

* process.c (rb_syswait): removed implicit signal handler change.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32510 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-10 17:04:40 +00:00
nobu 819c2418b1 * process.c (rb_exec_arg_addopt): fix preprocess condition.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32499 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-10 13:59:00 +00:00
kosaki 57da3d94aa comment clarification. Only Leopard or earlier has ENOTSUPP
issue if my kernel code reading is correct.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32468 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-09 04:18:09 +00:00
naruse 41ab31e67a * process.c (rb_daemon): fix wrong #endif position.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32263 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-28 01:20:23 +00:00
ko1 d1d5d5e798 * thread_pthread.c: Stop polling in the timer thread when there are
no waiting thread.  If there are 2 or more runnable threads,
  the timer thread does polling.  Avoid polling makes power save
  for several computers (0.2W per a Ruby process, when I measured).
  If outside-event such as signal or Thread#kill was occuerred
  when the timer thread does not do polling, then wake-up
  the timer thread using communication-pipe (the timer thread
  waits this communication-pipe with select(2)).
  The discussion about this modification can be found from the post
  [ruby-core:33456] and other related posts.
  Note that Eric Wong and KOSAKI Motohiro give us the huge
  contributions for this modification.  Thanks.
* thread_pthread.c (rb_thread_wakeup_timer_thread): add a function.
  This function wakes up the timer thread using communication-pipe.
* thread.c (rb_thread_stop_timer_thread): add a parameter which
  specify closing communication-pipe or not.
* thread.c (rb_thread_terminate_all): do not stop timer thread here
  (ruby_cleanup() terminate timer thread).
* signal.c: wake up timer thread using
  rb_thread_wakeup_timer_thread() from signal handler.
* eval.c (ruby_cleanup): use rb_thread_stop_timer_thread(1).
* process.c: use rb_thread_stop_timer_thread(0)
  (reuse communication-pipe).
* thread_win32.c (rb_thread_wakeup_timer_thread): add a dummy
  function.
* vm_core.h: add and fix decl. of functions.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32244 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-27 00:30:41 +00:00
nobu 706335aa0b * process.c (proc_daemon): should not start timer thread
twice.  fixed Bug#4920.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32221 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-24 08:06:38 +00:00
kosaki 1d110a14a4 * process.c (before_exec): use sig_do_nothing instead of SIG_DFL
for avoiding a race.
* process.c (sig_do_nothing): new function.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32178 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-20 13:55:04 +00:00
akr 7da3ea811e * method.h, internal.h iseq.h: declare internal functions.
* compile.c, eval.c, iseq.c, object.c, parse.y, proc.c, process.c,
  thread.c, vm.c, vm_eval.c, vm_insnhelper.c, vm_method.c: don't
  declare internal functions.

  Note that rb_method_entry_eq() is defined in vm_method.c but
  there was a declaration in proc.c with different const-ness.
  Now it is declared in method.h with same const-ness to the
  definition.

* object.c (rb_mod_module_exec): don't declare functions declared in
  include/ruby/intern.h.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32163 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-18 03:49:33 +00:00
akr e7996eb3cc * internal.h: declare internal functions here.
* node.h: declare NODE dependent internal functions here.

* iseq.h: declare rb_iseq_t dependent internal functions here.

* vm_core.h: declare rb_thread_t dependent internal functions here.

* bignum.c, class.c, compile.c, complex.c, cont.c, dir.c, encoding.c,
  enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c, io.c,
  iseq.c, load.c, marshal.c, math.c, numeric.c, object.c, parse.y,
  proc.c, process.c, range.c, rational.c, re.c, ruby.c, string.c,
  thread.c, time.c, transcode.c, variable.c, vm.c,
  tool/compile_prelude.rb: don't declare internal functions declared
  in above headers.  include above headers if required.

  Note that rb_thread_mark() was declared as
  void rb_thread_mark(rb_thread_t *th) in cont.c but defined as
  void rb_thread_mark(void *ptr) in vm.c.  Now it is declared as
  the later in internal.h.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 22:43:38 +00:00
kosaki ecaf7975cd * eval.c: remove rb_thread_stop_timer_thread function declaration.
Instead, include vm_core.h.
* process.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31927 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-05 14:35:09 +00:00
kosaki bde7a62f91 * process.c (before_exec, after_exec): change from macro to function.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31762 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-28 15:24:18 +00:00
kosaki ed02c4122a * process.c (before_exec, after_exec): change SIGPIPE handler to SIG_DFL
before calling execve(). Because r31760 reintroduced an issue that
  system() may hang up (i.e. [ruby-dev:12261]).
* process.c (save_sigpipe, restore_sigpipe): new.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31761 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-28 13:52:03 +00:00
nagachika 537a293669 * process.c (rb_proc_times): improve documentation.
[ruby-core:35785] fixes #4581, reported by Andrew Grimm.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31564 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-14 08:47:02 +00:00
drbrain e2b3183fc2 * re.c (Init_Regexp): Document option constants. Patch by Vincent
Batts.  [Ruby 1.9 - Bug #4677]
	* lib/uri/common.rb (module URI):  Documentation for URI.  Patch by
	  Vincent Batts.  [Ruby 1.9- Bug #4677]
	* lib/uri/ftp.rb (module URI):  ditto
	* lib/uri/generic.rb (module URI):  ditto
	* lib/uri/http.rb (module URI):  ditto
	* lib/uri/https.rb (module URI):  ditto
	* lib/uri/ldap.rb (module URI):  ditto
	* lib/uri/ldaps.rb (module URI):  ditto
	* lib/uri/mailto.rb (module URI):  ditto
	* process.c (Init_process):  Document Process constants.  Patch by
	  Vincent Batts.  [Ruby 1.9- Bug #4677]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31536 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-12 20:39:11 +00:00
kosaki bd90dc80f2 * process.c (proc_getmaxgroups, proc_setmaxgroups): Process#maxgroups
and Process#maxgroups= now raise NotImplementedError if the
  platform don't support supplementary groups concept.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31090 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-03-10 16:54:02 +00:00
kosaki 4a8cf2d92d * process.c (get_sc_ngroups_max): return -1 if platform don't
support NGROUPS_MAX.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31088 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-03-10 16:26:01 +00:00
kosaki 776156243c * process.c (proc_setgroups): cleanup.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31070 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-03-08 14:52:05 +00:00
nobu 6917c26a7a * process.c (get_sc_ngroups_max): fix indent.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-03-08 14:40:03 +00:00
kosaki d558bb59c8 * process.c (get_sc_ngroups_max): try to use NGROUPS_MAX at first if
_SC_NGROUP_MAX is not defined.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31067 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-03-08 14:29:22 +00:00
nobu 15f0e53a06 * process.c (proc_setgroups): use getgrnam() if getgrnam_r() is
not available.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31058 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-03-08 00:25:40 +00:00
nobu 487185de67 * process.c: RARRAY_LEN() returns long int.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31057 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-03-08 00:08:16 +00:00
naruse c57118f757 * process.c (get_sc_ngroups_max): define to wrap sysconf(3).
this also supports Windows which doesn't have sysconf(3).

* process.c (maxgroups): use get_sc_ngroups_max.

* process.c (proc_setmaxgroups): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31055 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-03-07 16:44:36 +00:00
naruse fe8e2dd1e1 * process.c (maxgroups): cast because sysconf(3)'s return value is long.
* process.c (proc_setmaxgroups): ditto.

* process.c (proc_setgroups): cast because RARRAY_LEN() is long.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31053 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-03-07 16:13:57 +00:00
kosaki 52b40be04b small cleanup.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31049 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-03-07 12:54:27 +00:00
kosaki 19a127d0cb * process.c (proc_setgroups): replace getgrnam() with getgrnam_r()
because getgrnam() isn't thread safe.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31048 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-03-07 12:35:45 +00:00
kosaki 1a8ee910f3 * process.c (proc_getmaxgroups, proc_setmaxgroups): refrect
platform maxgroups limitation by default instead hardcoded 65536.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31047 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-03-07 11:58:12 +00:00
matz 1df42597d1 cancel subversion backfire. sorry
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31046 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-03-07 08:44:45 +00:00
matz eb807d42ec * gc.c (rb_gc_set_params): allow GC parameter configuration by
environment variables.  based on a patch from funny-falcon at
  https://gist.github.com/856296, but honors safe level.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31044 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-03-07 08:39:39 +00:00
nobu 7b3c2c28dc * process.c: NUM2RLIM is defined but no getrlimit and setrlimit on
mingw.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31042 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-03-07 00:06:08 +00:00
kosaki c6bb8beb52 * process.c (proc_getgroups): get rid of maxgroups dependency.
ngroups can be calculated dynamically.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31037 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-03-06 15:25:58 +00:00
kosaki b1329e3b63 * configure.in: rlim_t use standard RUBY_REPLACE_TYPE mechanism.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31036 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-03-06 14:47:27 +00:00
kosaki beed971728 * process.c (proc_setmaxgroups): added negative value check.
This was suggested by Daniel Berger. Thanks Daniel!
  [ruby-core:35426][Bug#4467]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31035 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-03-06 14:28:02 +00:00
kosaki aca674c2e7 * process.c (maxgroups, proc_setmaxgroups): increase max groups
limitation up to 65536.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31034 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-03-06 14:21:31 +00:00
usa 4f8f4a9ee4 * process.c (check_exec_redirect_fd, check_exec_redirect): raise
ArgumentError if fd >= 3 on Windows because the feature is not
  supported.

* test/ruby/test_process.rb (test_execopts_redirect): remove meaningless
  argument.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31017 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-03-03 13:13:10 +00:00
kosaki 411e4a6cf2 * process.c (rb_run_exec_options_err): use MODET2NUM() instead LONG2NUM().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30822 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-02-08 07:01:23 +00:00
nagachika 012e60f61c * process.c (proc_setgroups): add GC guard to prevent intermediate
variable from GC.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30820 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-02-07 16:01:57 +00:00
kosaki 92c1dfd9d2 * configure.in: Added mode_t type checking.
* process.c (rb_exec_arg_addopt): Use NUM2MODET() instead
	  NUM2LONG because clang makes compile error by this narrowing
	  conversion.
	* process.c (rb_run_exec_options_err): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30685 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-01-28 02:00:08 +00:00
nobu fa57e46896 * process.c (ALLOC_ARGV_WITH_STR): fix void pointer arithmetic.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30663 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-01-27 03:46:44 +00:00
nobu beec203a1d * process.c (proc_exec_v, rb_proc_exec_n, rb_proc_exec)
(proc_spawn_n, proc_spawn): get rid of too huge alloca().
  [ruby-core:34827], [ruby-core:34833]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30662 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-01-26 23:41:47 +00:00