summaryrefslogtreecommitdiff
path: root/process.c
AgeCommit message (Collapse)Author
2016-11-06process.c: PATH env in spawnnobu
* process.c (rb_exec_fillarg): honor the given path environment variable. [ruby-core:53103] [Bug #8004] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56618 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-26[DOC] replace Fixnum with Integer [ci skip]nobu
* numeric.c: [DOC] update document for Integer class. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56492 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-14process.c: use uaspawnnobu
* process.c (proc_exec_cmd): use UTF-8 version aspawn. [ruby-dev:49838] [Bug #12841] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56424 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-09-24fid typos [ci skip]nobu
* fix typos, "a" before "Integer" to "an". [Fix GH-1438] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56225 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-09-21* process.c (InitVM_process): Support CLOCK_MONOTONIC_RAW_APPROX,naruse
CLOCK_UPTIME_RAW, and CLOCK_UPTIME_RAW_APPROX which are introduced by macOS 10.12. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56200 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-09-08replace fixnum by integer in documents.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56102 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-07-28* vm_core.h: revisit the structure of frame, block and env.ko1
[Bug #12628] This patch introduce many changes. * Introduce concept of "Block Handler (BH)" to represent passed blocks. * move rb_control_frame_t::flag to ep[0] (as a special local variable). This flags represents not only frame type, but also env flags such as escaped. * rename `rb_block_t` to `struct rb_block`. * Make Proc, Binding and RubyVM::Env objects wb-protected. Check [Bug #12628] for more details. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55766 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-07-04fix typonaruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55572 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-07-04* process.c: define sig_t if not exist.naruse
at least Solaris 10 and 11 doesn't have sig_t. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55571 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-07-02process.c (disable_child_handler_fork_child): simplifynormal
signal(2) is portable for SIG_DFL and SIG_IGN, so we do not need the extra code for sigaction(2). Also, execve will reset all signal handlers to default anyways, so there is little sense in preserving old signal handler besides SIG_IGN. Hopefully this makes the code easier-to-understand and maintain. * process.c (disable_child_handler_fork_child): simplify [ruby-core:75781] [Misc #12439] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55566 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-27process.c: [DOC] Process.abort [ci skip]nobu
* process.c (rb_f_abort): [DOC] Process.abort is a singleton method of Process, but not an instance method. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55183 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-20fix build on no-fork-spawnv platformsnobu
* process.c (rb_execarg_commandline): build command line string from argument vector in rb_execarg. [ruby-core:75611] [Bug #12398] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55091 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-08* configure.in: check function attirbute const and pure,naruse
and define CONSTFUNC and PUREFUNC if available. Note that I don't add those options as default because it still shows many false-positive (it seems not to consider longjmp). * vm_eval.c (stack_check): get rb_thread_t* as an argument to avoid duplicate call of GET_THREAD(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54952 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-08* configure.in: add -Wsuggest-attribute=noreturn and suppress warnings.naruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54943 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-06process.c: argument types over conversionnobu
* process.c (rb_exec_getargs): honor the expected argument types over the conversion method. the basic language functionality should be robust. [ruby-core:75388] [Bug #12355] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54934 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-02process.c (disable_child_handler_fork_child): initialize handler for SIGPIPEnormal
This only happens on the !POSIX_SIGNAL case; but one may test with the following: --- a/process.c +++ b/process.c @@ -3479,6 +3479,7 @@ disable_child_handler_fork_parent(struct child_handler_disabler_state *old) #endif } +#undef POSIX_SIGNAL /* This function should be async-signal-safe. Actually it is. */ static int disable_child_handler_fork_child(struct child_handler_disabler_state *old, char *errmsg, size_t errmsg_buflen) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54890 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-14process.c: prefer rb_check_aritynobu
* process.c: use rb_check_arity instead of rb_scan_args for simple optional arguments. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54573 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-27* process.c (rb_execarg_parent_start1): need to convert the encoding tousa
ospath's one. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53348 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-27* process.c (rb_execarg_addopt): need to convert to ospath.usa
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53347 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-27* process.c: use rb_w32_uchdir() instead of plain chdir() on Windows.usa
reported by naruse via twitter. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53346 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-23prefer rb_syserr_failnobu
* file.c, io.c, util.c: prefer rb_syserr_fail with saved errno over setting errno then call rb_sys_fail, not to be clobbered potentially and to reduce thread local errno accesses. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53264 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-14* enum.c: fix a typo in documentation.hsbt
[ci skip][fix GH-1140] Patch by @jutaz * io.c: ditto. * iseq.c: ditto. * numeric.c: ditto. * process.c: ditto. * string.c: ditto. * vm_trace.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53105 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-04process.c: fix rdoc of Process.getsid [ci skip]nobu
* process.c (proc_getsid): [DOC] Fix double word 'for' and typo. [Fix GH-1080] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52441 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-18* ChangeLog: Good-bye OS/2.kosaki
* common.mk: ditto. * configure.in: ditto. * dln_find.c: ditto. * ext/Setup.emx: ditto. * ext/extmk.rb: ditto. * ext/socket/extconf.rb: ditto. * ext/zlib/extconf.rb: ditto. * file.c: ditto. * include/ruby/defines.h: ditto. * io.c: ditto. * lib/mkmf.rb: ditto. * missing/os2.c: ditto. * process.c: ditto. * ruby.c: ditto. * NEWS: announce OS/2 is no longer supported. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52161 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-12process.c: do not inherit saved fdsnobu
* process.c (save_redirect_fd): make saved FDs close-on-exec not to be inherited. * process.c (run_exec_dup2): restore close-on-exec flags too. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51832 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-10Clarify spawn pgroup documentation [ci skip]nobu
* process.c (rb_f_spawn): Be more specific regarding "other values" by having "non-zero positive integers" Add nil, the default value, as a possible value and what it means. Try to use more consistent language. [Fix GH-1008] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51819 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-08process.c: keep GVL if WNOHANGnobu
* process.c (rb_waitpid): do not release GVL when WNOHANG is set, it should return immediately without blocking. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51793 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-08process.c: retry loopnobu
* process.c (rb_waitpid): refactor retry loop by interrupt. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51792 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-07process.c: open exception messagenobu
* process.c (rb_execarg_parent_start1): raise with the target path name when open() failed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51787 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-07process.c: chdir exception messagenobu
* process.c (rb_exec_fail): raise with the target directory name when chdir() failed. pointed out by sorah. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51786 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-02Fix typo in Process.detatch doc [ci skip]nobu
* process.c (proc_detach): [DOC] fix typo "intent" as "intend" in rdoc. [Fix GH-1011] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51739 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-19process.c: [DOC] env values in spawn [ci skip]nobu
* process.c (rb_f_spawn): [DOC] elaborate environment variable values. [ruby-core:70456] [Bug #11463] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51641 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-14improve handling of timer thread shutdownnormal
Shutting down the timer thread now always closes pipes to free FDs. In fact, we close the write ends of the pipes is done in the main RubyVM to signal the timer thread shutdown. To effectively close pipes, we implement userspace locks via atomics to force the pipe closing thread to wait on any signal handlers which may be waking up. While we're at it, improve robustness during resource exhaustion and allow it to limp along non-fatally if restarting a timer thread fails. This reverts r51268 Note: this change is tested with VM_CHECK_MODE 1 in vm_core.h * process.c (close_unless_reserved): add extra check (dup2_with_divert): remove (redirect_dup2): use dup2 without divert (before_exec_non_async_signal_safe): adjust call + comment (rb_f_exec): stop timer thread for all OSes (rb_exec_without_timer_thread): remove * eval.c (ruby_cleanup): adjust call * thread.c (rb_thread_stop_timer_thread): always close pipes * thread_pthread.c (struct timer_thread_pipe): add writing field, mark owner_process volatile for signal handlers (rb_thread_wakeup_timer_thread_fd): check valid FD (rb_thread_wakeup_timer_thread): set writing flag to prevent close (rb_thread_wakeup_timer_thread_low): ditto (CLOSE_INVALIDATE): new macro (close_invalidate): new function (close_communication_pipe): removed (setup_communication_pipe_internal): make errors non-fatal (setup_communication_pipe): ditto (thread_timer): close reading ends inside timer thread (rb_thread_create_timer_thread): make errors non-fatal (native_stop_timer_thread): close write ends only, always, wait for signal handlers to finish (rb_divert_reserved_fd): remove * thread_win32.c (native_stop_timer_thread): adjust (untested) (rb_divert_reserved_fd): remove * vm_core.h: adjust prototype git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-26revert r31760 and r31761nobu
seems that rb_bug_errno() is called in sigpipe() intentionally. https://gist.github.com/sorah/831169 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
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