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

689 Коммитов

Автор SHA1 Сообщение Дата
nobu d1fb37bca8 process.c: initgroups on cygwin
* process.c (initgroups): not declared on cygwin if _POSIX_SOURCE
  or _XOPEN_SOURCE are defined.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50304 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-14 02:25:02 +00:00
akr ff381ca19b * process.c (rb_execarg_parent_start1): Handle EINTR.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50207 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-10 09:45:29 +00:00
akr ce28a7539d * process.c: Release GVL when opening a file in spawn() to avoid whole
process blocking when opening a named pipe.
  (open_func): New function.
  (rb_execarg_parent_start1): Extracted from rb_execarg_parent_start and
  use rb_thread_call_without_gvl2 to release GVL when opening a file.
  (rb_execarg_parent_start): Invoke rb_execarg_parent_start1 via
  rb_protect and invoke rb_execarg_parent_end when error.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50198 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-09 16:33:02 +00:00
akr 6cf4e97b3e move debug functions.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50197 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-09 14:23:42 +00:00
akr 3bf92fb10d * process.c (redirect_open): Removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-09 13:19:47 +00:00
akr f6b1dd28c9 * internal.h (rb_execarg_parent_end): Declared.
* process.c: "spawn" opens files in the parent process.
  (check_exec_redirect): Add an placeholder for fd in parameters
  for fd_open.
  (check_exec_fds_1): Delete fd_open condition.
  (check_exec_fds): Don't call check_exec_fds_1 with fd_open.
  (rb_execarg_parent_start): Open files specified as "spawn" options
  and add "dup2" options.
  (rb_execarg_parent_end): New function to close opened fds.
  (run_exec_open): Removed.
  (rb_execarg_run_options): Don't call run_exec_open.
  (rb_spawn_internal): Call rb_execarg_parent_end.

* io.c (pipe_open): Call rb_execarg_parent_end.

* ext/pty/pty.c (establishShell): Call rb_execarg_parent_end.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50194 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-09 12:44:35 +00:00
akr 9960558337 * internal.h (rb_execarg_parent_start): Renamed from rb_execarg_fixup.
* process.c: Follows the above change.

* io.c: Ditto.

* ext/pty/pty.c: Ditto.




git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50193 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-09 11:53:49 +00:00
akr 00478a98ac * process.c (fd_clear_cloexec): Extracted from run_exec_dup2.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50192 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-09 11:35:52 +00:00
nobu 0d20fbe3bd eval.c: static IDs
* eval.c (ruby_static_id_signo, ruby_static_id_status): add static
  IDs, signo and status.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-23 07:05:30 +00:00
nobu 802d71a57e [DOC] ENV keys must be strings [ci skip]
* hash.c (env_aset): state that ENV keys must be strings.

* process.c (rb_f_spawn): ditto.  [ruby-core:68146] [Bug #10859]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49635 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-18 02:42:58 +00:00
nobu 76ec09062a process.c: missing parenthesis
* process.c (proc_detach): [DOC] fix missing closing parenthesis.
  [Fix GH-799]  [ci skip]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49053 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-29 01:37:07 +00:00
akr 81e9d9799a * process.c: Unused code removed.
It seems waitpid() is universaly available on POSIX platforms.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49037 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-27 08:03:29 +00:00
nobu 1db0393eb1 uninitialized variable
* process.c (rb_spawn_process): get rid of usage of uninitialized
  variable.
  reported by Denis Denisov <denji0k AT gmail.com>.
* regexec.c (match_at): ditto.
* ext/win32ole/win32ole.c (ole_wc2mb_alloc, ole_vstr2wc, ole_mb2wc):
  ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49025 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-26 06:09:11 +00:00
nobu 7307c32f1f process.c: unused variables
* process.c (rb_fork_async_signal_safe): remove initialized but
  never assigned local variables.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48769 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-11 03:02:36 +00:00
nobu e580a631be use 0 for reserved
use 0 for rb_data_type_t::reserved instead of NULL, since its type
may be changed in the future and possibly not a pointer type.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48662 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-01 06:38:04 +00:00
nobu 63aafb2004 process.c: initialize static IDs first
* process.c (Init_process): initialize static IDs before constant
  definitions.  [ruby-core:66445]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48556 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-25 03:14:45 +00:00
nobu 09fbd56e6f process.c: get rid of inadvertent ID pindown
* process.c (check_exec_redirect_fd, check_exec_redirect),
  (rb_execarg_addopt): get rid of inadvertent ID pindown.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48552 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-24 03:44:45 +00:00
nobu a6755b6e5f process.c: intern IDs
* process.c (Init_process): intern IDs at initialization.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48551 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-24 03:44:24 +00:00
akr 7cd76ab0c5 * internal.h: Include ruby.h and ruby/encoding.h to be
includable without prior inclusion.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-15 11:49:06 +00:00
yugui 57bc5eaf2f Fixes build failures on Portable Native Client.
Note: Some of the fixes are for newlib in general but not NaCl-specific.

* include/ruby/intern.h (rb_fd_select): declare struct timeval, or the
  struct gets local to the function in C99.

* file.c (#include): add nacl/stat.h for PNaCl.
  (utimes): added a declaration for PNaCl.
  (stat_atimespec): stat::st_atimensec is long long but
  timespec::tv_nsec is long in PNaCl.
  (stat_mtimespec, stat_ctimespec): ditto.
  (rb_group_member): disable getgroups unless HAVE_GETGROUPS.
  (eaccess): unify the fallback to generic defined(USE_GETEUID).

* io.c: include sys/time.h for struct timeval.
  (rb_close_before_exec): nothing we can do if F_GETFD is not
  available.
  (ioctl): pnacl newlib actually doesn't have ioctl.

* process.c (maxgroups): it is used iff
   defined(_SC_NGROUPS_MAX) || defined(NGROUPS_MAX) but not
   defined(HAVE_GETGROUPS) || defined(HAVE_SETGROUPS).
  (obj2gid): fail unless the object is a Fixnum if getgrnam is not
  available.
  (disable_child_handler_fork_child): sigaction is not available in
  PNaCl newlib.

* configure.in (warnflags, strict_warnflags): avoid -ansi for strlcpy.
  (rb_cv_gcc_atomic_builtins): also check
  __atomic_or_etch because it is used in ruby_atomic.h.
  (rb_cv_gcc_sync_builtins): ditto.
  (HAVE_GETGRNAM): added.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47882 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-11 13:33:14 +00:00
nobu 28b9f11d5a protoize no-arguments functions
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47744 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-30 05:25:32 +00:00
normal d198d64e04 trivial packing for on-stack structs
* io.c (struct io_advise_struct): 32 => 24 bytes on 64-bit
* io.c (struct io_internal_writev_struct): 24 => 16 bytes on 64-bit
* process.c (struct waitpid_arg): ditto

Slightly reduce stack pressure.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47594 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-15 07:31:38 +00:00
normal d2e3c03409 simplify some trivial rb_data_type_t callbacks
* process.c (free_exec_arg): remove
  (memsize_exec_arg): ptr is never NULL
  (exec_arg_data_type): use RUBY_TYPED_DEFAULT_FREE

* variable.c (autoload_i_free): remove
  (autoload_data_i_type): use RUBY_TYPED_DEFAULT_FREE
  (autoload_memsize): ptr is never NULL

* vm_backtrace.c (location_free): remove
  (location_mark): ptr is never NULL
  (location_data_type): use RUBY_TYPED_DEFAULT_FREE
  (backtrace_mark): ditto
  (backtrace_free): ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47572 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-13 05:14:51 +00:00
normal afa512d9e1 Process.detach: avoid singleton class creation
* process.c (Init_process): subclass Thread as Process::Waiter
  (rb_detach_process): use Process::Waiter instead of singleton class

* test/ruby/test_process.rb (test_process_detach): new test

* inits.c (rb_call_inits): call Init_Thread before Init_process to
  ensure Process::Waiter may be a subclass of Thread

Thanks to headius for reporting [Bug #10231]
Thanks to nobu for review of my initial patch.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47561 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-12 19:42:01 +00:00
akr e6368921ea * process.c: PTHREAD_CANCEL_DISABLE is not defined on Android.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47443 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-07 03:47:47 +00:00
nobu ed0a7d4627 process.c: disable vfork on OS X
* process.c (retry_fork_async_signal_safe): revert r47439 but
  disable use of vfork on OS X instead, as it cause hang-up at
  test_process.rb:test_deadlock_by_signal_at_forking with parallel
  test.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47441 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-07 01:57:44 +00:00
nobu e81a0d8f36 process.c: vfork may not work with pthread
* process.c (retry_fork_async_signal_safe): vfork may not work
  with pthread always even if fork works with it.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47439 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-07 01:10:43 +00:00
akr 11a8187bd1 * process.c (has_privilege): The gid zero is not a privilege.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47438 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-06 12:08:02 +00:00
akr 42becbddc2 * process.c (struct child_handler_disabler_state): cancelstate field
added.
  (disable_child_handler_before_fork): Record cancelstate.
  (disable_child_handler_fork_parent): Restore cancelstate.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47437 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-06 11:20:08 +00:00
akr 3de392def9 * process.c (struct child_handler_disabler_state): Defined.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47436 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-06 10:27:54 +00:00
nobu c54e8cabe8 process.c: missing semicolon
* process.c (rb_exec_without_timer_thread): add missing semicolon
  to fix compilation error on OS X and Haiku.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47424 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-05 23:45:11 +00:00
akr 3146827521 * process.c (rb_f_exec): Call before_exec_async_signal_safe and
after_exec_async_signal_safe around rb_exec_async_signal_safe.
  (rb_exec_async_signal_safe): Don't call
  before_exec_async_signal_safe and after_exec_async_signal_safe.
  (rb_exec_without_timer_thread): Call before_exec and
  after_exec.
  (disable_child_handler_fork_child): Make SIGPIPE handler SIG_DFL.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47421 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-05 16:36:35 +00:00
akr 2942657a56 Unwrap a useless block.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47420 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-05 16:10:16 +00:00
akr 0610a859d9 * process.c (disable_child_handler_before_fork): New function.
(disable_child_handler_fork_parent): Ditto.
  (disable_child_handler_fork_child): Ditto.
  (retry_fork_async_signal_safe): Call above functions to disable
  signal handlers in child process.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47412 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-05 12:46:09 +00:00
akr 01689aa9b1 * process.c (handle_fork_error): Make try_gc_p argument volatile to
suppress "clobbered" warning.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47411 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-05 12:03:54 +00:00
akr 5e42cc3085 * process.c (handle_fork_error): Don't need state_p argument.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47410 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-05 11:49:04 +00:00
akr 4eed59e667 * process.c (has_privilege): Fix a return value.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47409 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-05 11:36:19 +00:00
akr 192c39532b * process.c (has_privilege): Refine uid/gid check.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47398 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-05 03:58:42 +00:00
akr 82d85fe441 * configure.in: Check sys/id.h, getuidx and getgidx for AIX.
* process.c (getresuid): Defined for AIX.
  (getresgid): Ditto
  AIX don't have getresuid/getresgid but getuidx/getgidx.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47397 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-05 03:43:28 +00:00
akr 2cf2d7ee20 * process.c (has_privilege): Fix assignements.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47396 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-05 03:28:53 +00:00
akr f20d51b0ad * process.c (has_privilege): New function.
(retry_fork_async_signal_safe): Don't use vfork() for privileged
  process.

* configure.in (getresuid): Check function.
  (getresgid): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47386 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-04 14:56:03 +00:00
akr 777d61faf4 * process.c (before_fork_ruby): Renamed from before_fork.
(after_fork_ruby): Renamed from after_fork.




git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47374 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-03 10:23:24 +00:00
akr ed0f2528e8 * process.c (forked_child): Removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47373 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-03 09:56:38 +00:00
akr 9b16f90692 * process.c (retry_fork_async_signal_safe): Use vfork() if available.
vfork() is still faster than fork() especially when the parent
  process uses big memory.

  ruby -rbenchmark -e 'a = "a" * 1_000_000_000; puts Benchmark.measure { system("true") }'
  fork:   0.000000   0.010000   0.010000 (  0.014968)
  vfork:  0.000000   0.000000   0.000000 (  0.000912)
  on Debian sid.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47363 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-03 03:06:17 +00:00
akr 93a7bf4b17 * configure.in: Use AC_FUNC_FORK.
* io.c: Use HAVE_WORKING_FORK instead of HAVE_FORK.

* process.c: Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47361 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-02 22:51:03 +00:00
akr 34af76e318 * process.c (retry_fork_async_signal_safe): Don't return on in child
process.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47358 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-02 15:13:36 +00:00
akr 93621161d6 * process.c (retry_fork_async_signal_safe): Specialized version of
retry_fork respect to rb_fork_async_signal_safe.
  (retry_fork_ruby): Specialized version of retry_fork respect to
  rb_fork_ruby.
  (rb_fork_ruby): Removed.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47357 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-02 14:47:46 +00:00
akr de88408813 * process.c (send_child_error): Simplified.
(recv_child_error): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47356 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-02 14:27:10 +00:00
akr a78a9b0d17 * process.c (rb_fork_async_signal_safe): Inline rb_fork_internal.
(rb_fork_ruby): Ditto.
  (rb_fork_internal): Removed.
  (chfunc_protect): Removed.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47355 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-02 13:56:35 +00:00
akr 557802a1da * process.c (handle_fork_error): Extracted from retry_fork.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47351 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-02 11:47:35 +00:00