summaryrefslogtreecommitdiff
path: root/process.c
AgeCommit message (Collapse)Author
2015-07-16avoid redundant GET_THREAD() callsnormal
This reduces binary size slightly on my 32-bit system: text data bss dec hex filename 2847705 12360 30632 2890697 2c1bc9 ruby.orig 2847641 12360 30632 2890633 2c1b89 ruby * iseq.c (rb_iseq_compile_with_option): reuse result of previous GET_THREAD() call * thread.c (thread_create_core): ditto (rb_mutex_trylock): ditto (rb_mutex_lock): ditto * process.c (rb_waitpid): avoid multiple eval from RUBY_VM_CHECK_INTS * thread.c (rb_thread_check_ints): ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51273 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-16* process.c (redirect_dup2): when the new FD of dup2() coflictsngoto
with one of the timer thread FDs, the internal FD is diverted. [Bug #11336] [ruby-core:69886] [Bug #11350] [ruby-core:69961] * process.c (dup2_with_divert): new function for the above purpose. * thread_pthread.c (rb_divert_reserved_fd): new function for diverting reserved FD. If the given FD is the same as one of the reserved FDs, the reserved FD number is internally changed. It returns -1 when error. Otherwise, returns 0. It also returns 0 if there is no need to change reserved FD number. * thread_win32.c (rb_divert_reserved_fd): always returns 0 because of no reserved FDs. * internal.h (rb_divert_reserved_fd): prototype declaration. It is Ruby internal use only. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51268 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-16Revert r51209 because signals after stopping timer thread beforengoto
entering exec(2) system call may be lost. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51265 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-16process.c (close_unless_reserved): declare type of `fd' argnormal
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51262 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-15* process.c (redirect_close, parent_redirect_close): should not closengoto
reserved FD. It should be closed in the exec system call due to the O_CLOEXEC or FD_CLOEXEC flag. [Bug #11353] [ruby-core:69977] * process.c (close_unless_reserved): new function to close FD unless it is reserved for internal communication. * thread_pthread.c (rb_reserved_fd_p): should check owner_process pid to avoid false positive in forked child process. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51255 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-10* process.c (rb_f_exec): rb_exec_without_timer_thread should bengoto
used on every OS, not only on Mac OS X or Haiku, to prevent timer thread communications using file descriptor 3 after setting redirection of the fd 3 before calling exec. [Bug #11336] [ruby-core:69886] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51209 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-19* process.c (rb_execarg_parent_start1): new macro ALWAYS_NEED_ENVPngoto
to generate envp_str anytime on Solaris 10 (or earlier version of Solaris) to avoid calling execv() which is async-signal unsafe on Solaris 10. [Bug #11265] [ruby-dev:49089] * process.c (exec_with_sh, proc_exec_cmd): On Solaris 10, because ALWAYS_NEED_ENVP is 1 and envp_str is always generated, execv() in exec_with_sh() and proc_exec_cmd() are never called. To guarantee this, execv() is replaced by a macro to print out error message on Solaris 10. * process.c (proc_exec_sh): Because proc_exec_sh() may be called by rb_proc_exec() with envp_str = Qfalse, execl() is replaced by a macro that calls execle() with "extern char **environ" traditional global variable on Solaris 10. TODO: This may be unsafe and sholud be changed in the future. Although rb_proc_exec() is not used from inside current version of ruby, it may be called by third-party extensions. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50977 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-18* include/ruby/ruby.h: $SAFE=2 is now obsolete.hsbt
* dir.c, ext/fiddle/handle.c, ext/socket/basicsocket.c, file.c gc.c, io.c, process.c, safe.c, signal.c, win32/file.c: removed code for $SAFE=2 * test/erb/test_erb.rb, test/fiddle/test_handle.rb test/ruby/test_env.rb: removed tests for $SAFE=2. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50958 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-22process.c: do not discard statusnobu
* process.c (rb_spawn_process): do not discard global escape status. [ruby-core:69304] [Bug #11166] * process.c (rb_execarg_spawn): extract the start procedure in a parent process with ensuring the end procedure. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50600 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-14process.c: initgroups on cygwinnobu
* 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-10* process.c (rb_execarg_parent_start1): Handle EINTR.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50207 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-09* process.c: Release GVL when opening a file in spawn() to avoid wholeakr
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-09move debug functions.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50197 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-09* process.c (redirect_open): Removed.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-09* internal.h (rb_execarg_parent_end): Declared.akr
* 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* internal.h (rb_execarg_parent_start): Renamed from rb_execarg_fixup.akr
* 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* process.c (fd_clear_cloexec): Extracted from run_exec_dup2.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50192 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-23eval.c: static IDsnobu
* 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-18[DOC] ENV keys must be strings [ci skip]nobu
* 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
2014-12-29process.c: missing parenthesisnobu
* 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-27* process.c: Unused code removed.akr
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-26uninitialized variablenobu
* 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-11process.c: unused variablesnobu
* 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-01use 0 for reservednobu
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-11-25process.c: initialize static IDs firstnobu
* 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-24process.c: get rid of inadvertent ID pindownnobu
* 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-24process.c: intern IDsnobu
* 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-15* internal.h: Include ruby.h and ruby/encoding.h to beakr
includable without prior inclusion. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-11Fixes build failures on Portable Native Client.yugui
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-09-30protoize no-arguments functionsnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47744 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-15trivial packing for on-stack structsnormal
* 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-13simplify some trivial rb_data_type_t callbacksnormal
* 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-12Process.detach: avoid singleton class creationnormal
* 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-07* process.c: PTHREAD_CANCEL_DISABLE is not defined on Android.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47443 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-07process.c: disable vfork on OS Xnobu
* 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-07process.c: vfork may not work with pthreadnobu
* 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-06* process.c (has_privilege): The gid zero is not a privilege.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47438 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-06* process.c (struct child_handler_disabler_state): cancelstate fieldakr
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* process.c (struct child_handler_disabler_state): Defined.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47436 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-05process.c: missing semicolonnobu
* 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* process.c (rb_f_exec): Call before_exec_async_signal_safe andakr
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-05Unwrap a useless block.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47420 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-05* process.c (disable_child_handler_before_fork): New function.akr
(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* process.c (handle_fork_error): Make try_gc_p argument volatile toakr
suppress "clobbered" warning. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47411 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-05* process.c (handle_fork_error): Don't need state_p argument.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47410 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-05* process.c (has_privilege): Fix a return value.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47409 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-05* process.c (has_privilege): Refine uid/gid check.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47398 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-05* configure.in: Check sys/id.h, getuidx and getgidx for AIX.akr
* 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* process.c (has_privilege): Fix assignements.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47396 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-04* process.c (has_privilege): New function.akr
(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