aboutsummaryrefslogtreecommitdiffstats
path: root/process.c
Commit message (Collapse)AuthorAgeFilesLines
...
* * process.c (rb_execarg_parent_start1): new macro ALWAYS_NEED_ENVPngoto2015-06-191-4/+13
| | | | | | | | | | | | | | | | | | | | | | | | 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
* * include/ruby/ruby.h: $SAFE=2 is now obsolete.hsbt2015-06-181-25/+0
| | | | | | | | | | * 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
* process.c: do not discard statusnobu2015-05-221-18/+41
| | | | | | | | | * 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
* process.c: initgroups on cygwinnobu2015-04-141-0/+3
| | | | | | | * 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
* * process.c (rb_execarg_parent_start1): Handle EINTR.akr2015-04-101-13/+15
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50207 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * process.c: Release GVL when opening a file in spawn() to avoid wholeakr2015-04-091-15/+69
| | | | | | | | | | | | | 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
* move debug functions.akr2015-04-091-59/+59
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50197 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * process.c (redirect_open): Removed.akr2015-04-091-10/+0
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * internal.h (rb_execarg_parent_end): Declared.akr2015-04-091-63/+71
| | | | | | | | | | | | | | | | | | | | | | * 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
* * internal.h (rb_execarg_parent_start): Renamed from rb_execarg_fixup.akr2015-04-091-4/+4
| | | | | | | | | | | | | * 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
* * process.c (fd_clear_cloexec): Extracted from run_exec_dup2.akr2015-04-091-15/+24
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50192 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* eval.c: static IDsnobu2015-02-231-2/+3
| | | | | | | * 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
* [DOC] ENV keys must be strings [ci skip]nobu2015-02-181-0/+2
| | | | | | | | * 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
* process.c: missing parenthesisnobu2014-12-291-1/+1
| | | | | | | * 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
* * process.c: Unused code removed.akr2014-12-271-96/+4
| | | | | | | | 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
* uninitialized variablenobu2014-12-261-0/+1
| | | | | | | | | | | * 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
* process.c: unused variablesnobu2014-12-111-5/+2
| | | | | | | * 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
* use 0 for reservednobu2014-12-011-1/+1
| | | | | | | 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
* process.c: initialize static IDs firstnobu2014-11-251-1/+7
| | | | | | | * 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
* process.c: get rid of inadvertent ID pindownnobu2014-11-241-6/+7
| | | | | | | * 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
* process.c: intern IDsnobu2014-11-241-50/+109
| | | | | | * 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
* * internal.h: Include ruby.h and ruby/encoding.h to beakr2014-11-151-2/+1
| | | | | | | | includable without prior inclusion. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Fixes build failures on Portable Native Client.yugui2014-10-111-2/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* protoize no-arguments functionsnobu2014-09-301-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47744 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* trivial packing for on-stack structsnormal2014-09-151-1/+1
| | | | | | | | | | * 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
* simplify some trivial rb_data_type_t callbacksnormal2014-09-131-8/+2
| | | | | | | | | | | | | | | | | | * 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
* Process.detach: avoid singleton class creationnormal2014-09-121-1/+8
| | | | | | | | | | | | | | | * 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
* * process.c: PTHREAD_CANCEL_DISABLE is not defined on Android.akr2014-09-071-0/+4
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47443 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* process.c: disable vfork on OS Xnobu2014-09-071-2/+2
| | | | | | | | | * 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
* process.c: vfork may not work with pthreadnobu2014-09-071-1/+3
| | | | | | | * 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
* * process.c (has_privilege): The gid zero is not a privilege.akr2014-09-061-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47438 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * process.c (struct child_handler_disabler_state): cancelstate fieldakr2014-09-061-0/+13
| | | | | | | | | | 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
* * process.c (struct child_handler_disabler_state): Defined.akr2014-09-061-10/+15
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47436 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* process.c: missing semicolonnobu2014-09-051-1/+1
| | | | | | | * 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
* * process.c (rb_f_exec): Call before_exec_async_signal_safe andakr2014-09-051-13/+21
| | | | | | | | | | | | | 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
* Unwrap a useless block.akr2014-09-051-8/+4
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47420 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * process.c (disable_child_handler_before_fork): New function.akr2014-09-051-2/+79
| | | | | | | | | | (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
* * process.c (handle_fork_error): Make try_gc_p argument volatile toakr2014-09-051-2/+2
| | | | | | | | suppress "clobbered" warning. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47411 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * process.c (handle_fork_error): Don't need state_p argument.akr2014-09-051-9/+9
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47410 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * process.c (has_privilege): Fix a return value.akr2014-09-051-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47409 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * process.c (has_privilege): Refine uid/gid check.akr2014-09-051-4/+4
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47398 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * configure.in: Check sys/id.h, getuidx and getgidx for AIX.akr2014-09-051-0/+39
| | | | | | | | | | * 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
* * process.c (has_privilege): Fix assignements.akr2014-09-051-4/+4
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47396 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * process.c (has_privilege): New function.akr2014-09-041-1/+70
| | | | | | | | | | | | (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
* * process.c (before_fork_ruby): Renamed from before_fork.akr2014-09-031-7/+7
| | | | | | | | | (after_fork_ruby): Renamed from after_fork. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47374 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * process.c (forked_child): Removed.akr2014-09-031-20/+11
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47373 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * process.c (retry_fork_async_signal_safe): Use vfork() if available.akr2014-09-031-0/+8
| | | | | | | | | | | | | | 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
* * configure.in: Use AC_FUNC_FORK.akr2014-09-021-15/+15
| | | | | | | | | | * 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
* * process.c (retry_fork_async_signal_safe): Don't return on in childakr2014-09-021-17/+17
| | | | | | | | process. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47358 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * process.c (retry_fork_async_signal_safe): Specialized version ofakr2014-09-021-27/+44
| | | | | | | | | | | 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