summaryrefslogtreecommitdiff
path: root/process.c
Commit message (Collapse)AuthorAgeFilesLines
* merge revision(s) 35249,35250: [Backport #6296]naruse2012-04-141-17/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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] * test/ruby/test_thread.rb (TestThreadGroup#test_thread_timer_and_interrupt): skip on Windows. Process.kill cannot kill a subprocess if CREATE_NEW_PROCESS_GROUP flag is not specified in a call to CreateProcessW(). * win32/win32.c (CreateChild): revert the usage of CREATE_NEW_PROCESS_GROUP flag for compatibility. [ruby-core:43245][Bug #6131] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@35332 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* merge revision(s) 35221:nobu2012-04-031-6/+8
| | | | | | | | * process.c (setreuid, setregid): suppress warnings. [ruby-core:43374][Bug #6169] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@35222 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * process.c (proc_spawn_v, proc_spawn): should not wait thenobu2011-08-191-9/+22
| | | | | | | | | 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/branches/ruby_1_9_3@33009 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * backport r32579, r32581, r32587 by akr and r32588 by kazu.akr2011-07-201-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | r32579: * io.c (rb_update_max_fd): new function. * internal.h (rb_update_max_fd): declare rb_update_max_fd. * thread_pthread.c (rb_thread_create_timer_thread): update max fd when timer thread pipe is created. r32581: * io.c (UPDATE_MAXFD): removed. r32587: * 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. r32588: * io.c (rb_update_max_fd): remove parentheses. they are not in macro. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@32591 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * process.c (rb_exec_arg_addopt): fix preprocess condition.nobu2011-07-101-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32499 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* comment clarification. Only Leopard or earlier has ENOTSUPP kosaki2011-07-091-3/+3
| | | | | | | | 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
* * process.c (rb_daemon): fix wrong #endif position.naruse2011-06-281-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32263 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * thread_pthread.c: Stop polling in the timer thread when there areko12011-06-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* * process.c (proc_daemon): should not start timer threadnobu2011-06-241-9/+9
| | | | | | twice. fixed Bug#4920. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32221 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * process.c (before_exec): use sig_do_nothing instead of SIG_DFLkosaki2011-06-201-1/+7
| | | | | | | | | 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
* * method.h, internal.h iseq.h: declare internal functions.akr2011-06-181-2/+0
| | | | | | | | | | | | | | | | | | * 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
* * internal.h: declare internal functions here.akr2011-06-171-5/+1
| | | | | | | | | | | | | | | | | | | | | | | | | * 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
* * eval.c: remove rb_thread_stop_timer_thread function declaration.kosaki2011-06-051-4/+0
| | | | | | | | | 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
* * process.c (before_exec, after_exec): change from macro to function.kosaki2011-05-281-13/+27
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31762 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * process.c (before_exec, after_exec): change SIGPIPE handler to SIG_DFLkosaki2011-05-281-7/+29
| | | | | | | | | | 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
* * process.c (rb_proc_times): improve documentation.nagachika2011-05-141-4/+4
| | | | | | [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
* * re.c (Init_Regexp): Document option constants. Patch by Vincentdrbrain2011-05-121-0/+77
| | | | | | | | | | | | | | | | | | 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
* * process.c (proc_getmaxgroups, proc_setmaxgroups): Process#maxgroupskosaki2011-03-101-2/+10
| | | | | | | | | 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
* * process.c (get_sc_ngroups_max): return -1 if platform don'tkosaki2011-03-101-1/+1
| | | | | | | | support NGROUPS_MAX. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31088 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * process.c (proc_setgroups): cleanup.kosaki2011-03-081-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31070 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * process.c (get_sc_ngroups_max): fix indent.nobu2011-03-081-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * process.c (get_sc_ngroups_max): try to use NGROUPS_MAX at first ifkosaki2011-03-081-0/+2
| | | | | | | | _SC_NGROUP_MAX is not defined. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31067 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * process.c (proc_setgroups): use getgrnam() if getgrnam_r() isnobu2011-03-081-3/+9
| | | | | | not available. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31058 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * process.c: RARRAY_LEN() returns long int.nobu2011-03-081-8/+12
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31057 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * process.c (get_sc_ngroups_max): define to wrap sysconf(3).naruse2011-03-071-2/+10
| | | | | | | | | | 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
* * process.c (maxgroups): cast because sysconf(3)'s return value is long.naruse2011-03-071-3/+3
| | | | | | | | * 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
* small cleanup.kosaki2011-03-071-6/+6
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31049 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * process.c (proc_setgroups): replace getgrnam() with getgrnam_r()kosaki2011-03-071-5/+16
| | | | | | | | because getgrnam() isn't thread safe. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31048 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * process.c (proc_getmaxgroups, proc_setmaxgroups): refrectkosaki2011-03-071-6/+21
| | | | | | | | 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
* cancel subversion backfire. sorrymatz2011-03-071-29/+51
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31046 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * gc.c (rb_gc_set_params): allow GC parameter configuration bymatz2011-03-071-51/+29
| | | | | | | 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
* * process.c: NUM2RLIM is defined but no getrlimit and setrlimit onnobu2011-03-071-6/+6
| | | | | | mingw. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31042 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * process.c (proc_getgroups): get rid of maxgroups dependency.kosaki2011-03-061-2/+6
| | | | | | | | ngroups can be calculated dynamically. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31037 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * configure.in: rlim_t use standard RUBY_REPLACE_TYPE mechanism.kosaki2011-03-061-11/+0
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31036 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * process.c (proc_setmaxgroups): added negative value check.kosaki2011-03-061-1/+4
| | | | | | | | | 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
* * process.c (maxgroups, proc_setmaxgroups): increase max groupskosaki2011-03-061-3/+24
| | | | | | | | limitation up to 65536. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31034 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * process.c (check_exec_redirect_fd, check_exec_redirect): raiseusa2011-03-031-6/+11
| | | | | | | | | | | 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
* * process.c (rb_run_exec_options_err): use MODET2NUM() instead LONG2NUM().kosaki2011-02-081-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30822 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * process.c (proc_setgroups): add GC guard to prevent intermediatenagachika2011-02-071-1/+3
| | | | | | variable from GC. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30820 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * configure.in: Added mode_t type checking.kosaki2011-01-281-2/+2
| | | | | | | | | | | * 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
* * process.c (ALLOC_ARGV_WITH_STR): fix void pointer arithmetic.nobu2011-01-271-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30663 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * process.c (proc_exec_v, rb_proc_exec_n, rb_proc_exec)nobu2011-01-261-18/+43
| | | | | | | (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
* update doc.akr2010-12-291-3/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30417 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * process.c (before_exec): add small comment.kosaki2010-12-261-0/+4
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30387 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * process.c: parenthesize macro arguments.akr2010-12-231-9/+9
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30329 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * process.c (p_uid_change_privilege, p_gid_change_privilege):nobu2010-11-051-6/+10
| | | | | | suppress warnings. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29705 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * process.c (rb_fork_err): save errinfo before fdopen.nobu2010-11-051-1/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29701 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * process.c (proc_spawn_v): should spawn, not exec.nobu2010-11-051-1/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29697 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * process.c (proc_exec_v, proc_spawn_v): try to execute with sh ifnobu2010-11-041-7/+25
| | | | | | no shebang. [ruby-core:32745] [EXPERIMENTAL] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29695 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* update document.akr2010-09-121-0/+8
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29231 b2dd03c8-39d4-4d8f-98ff-823fe69b080e