This affects test/ruby/test_process.rb (test_execopt_env_path).
Since MJIT uses vfork+execve in a separate thread, there can be
small window in-between vfork and execve where tmp_script.cmd is
held open by the vforked child. vfork only pauses the MJIT
thread, not any Ruby Threads, so our call to Process.spawn will
hit ETXTBUSY in that window unless we fork.
main thread | MJIT thread
----------------------------------------------------
fd = open(tmp) | |
| vfork for CC | CC running
write | | ---------------
fchmod | | sees "fd" here
close(fd) | |
Process.spawn called | |
vfork (spawn)| (new process) | |
| execve => TXTBUSY | |
| | | execve (FD_CLOEXEC on fd)
| | vfork returns |
Holding the waitpid_lock whenever we intend to spawn a process
prevents the MJIT thread from spawning a process while we are
spawning in Ruby-land.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66171 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
io.c has not used it since r36229, and we can re-export
it if we need it at another time.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66157 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
TypedData_* macros hide assignments and are confusing and too
long for users of giant fonts.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
because JIT-ed code may still be on stack at this time, unlike
in ruby_cleanup().
This hopes to fix: (take 2)
http://ci.rvm.jp/results/trunk-mjit-wait@silicon-docker/1480207
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65999 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
http://ci.rvm.jp/results/trunk-mjit-wait@silicon-docker/1480173
It tries to print C backtrace but fails. And core file on the server
seems to be stopping on the irrelevant place due to its own signal
handler for the dump.
And I failed to reproduce this SEGV on my machine.
I don't know why it's broken, so let me try this change to investigate
the reason of SEGV.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65997 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
to prevent ruby from leaving MJIT-related files.
test_jit.rb: add a test to prevent that
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65994 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
All normal Ruby IO methods (IO#read, IO#gets, IO#write, ...) are
all capable of appearing to be "blocking" when presented with a
file description with the O_NONBLOCK flag set; so there is
little risk of incompatibility within Ruby-using programs.
The biggest compatibility risk is when spawning external
programs. As a result, stdin, stdout, and stderr are now always
made blocking before exec-family calls.
This change will make an event-oriented MJIT usable if it is
waiting on pipes on POSIX_like platforms.
It is ALSO necessary to take advantage of (proposed lightweight
concurrency (aka "auto-Fiber") or any similar proposal for
network concurrency: https://bugs.ruby-lang.org/issues/13618
Named-pipe (FIFO) are NOT yet non-blocking by default since
they are rarely-used and may introduce compatibility problems
and extra syscall overhead for a common path.
Please revert this commit if there are problems and if I am afk
since I am afk a lot, lately.
[ruby-core:89950] [Bug #14968]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65922 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
while child handler is disabled.
trying to fix [Bug #15320]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65817 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
it didn't work.
http://ci.rvm.jp/results/trunk-mjit@silicon-docker/1468677
and skips broken tests for now. But this issue should be fixed soon.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65814 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
to prevent from proceeding one for MJIT while it's not safe yet.
By that situation, MJIT worker could be waiting for compiler process forever
http://ci.rvm.jp/results/trunk-mjit@silicon-docker/1468033
[Bug #15320]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65807 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
by launching MJIT worker thread in child Ruby process.
See the comment before `mjit_child_after_fork` for details.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65785 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* hash.c, internal.h: support theap for small Hash.
Introduce RHASH_ARRAY (li_table) besides st_table and small Hash
(<=8 entries) are managed by an array data structure.
This array data can be managed by theap.
If st_table is needed, then converting array data to st_table data.
For st_table using code, we prepare "stlike" APIs which accepts hash value
and are very similar to st_ APIs.
This work is based on the GSoC achievement
by tacinight <tacingiht@gmail.com> and refined by ko1.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65454 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Following how mjit_worker.c currently works, rb_f_system
now ensures the VM-wide waitpid lists is locked before
creating a new process via fork/vfork.
This ensures other rb_waitpid callers cannot steal work and
there are no possible race conditions from toggling
ruby_nocldwait without the use of atomics.
This sets us up for implementing MJIT process management
logic using normal Ruby APIs prepares us for VM-wide
asynchronous/event-base waitpid which can allow MJIT to
work without worker threads.
Take 2: set waitpid_state.pid on platforms w/o fork.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65437 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Following how mjit_worker.c currently works, rb_f_system
now ensures the VM-wide waitpid lists is locked before
creating a new process via fork/vfork.
This ensures other rb_waitpid callers cannot steal work and
there are no possible race conditions from toggling
ruby_nocldwait without the use of atomics.
This sets us up for implementing MJIT process management
logic using normal Ruby APIs prepares us for VM-wide
asynchronous/event-base waitpid which can allow MJIT to
work without worker threads.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65434 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
rb_hrtime_t is a more pleasant type to use and this can make
future changes around sleeping/scheduling easier.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65182 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* process.c (check_exec_redirect): use RARRAY_AREF() instead of
using RARRAY_PTR().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64987 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This is the safer option, as there seems to be cases where checking
waitpid_state.ret is insufficient in ensure. I'm not 100% sure
why this is, but this change was required for my work-in-progress
Thread::Light patch series, too...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64782 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Oddly, all existing test cases passed multiple times
before this patch (even with --jit-wait), so this seems
like a difficult failure to prove.
Fixes: r64576 ("process.c: simplify SIGCHLD-based waitpid")
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64577 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Introduce a new rb_thread_sleep_interruptible that does not
execute interrupts before sleeping. Skipping the interrupt
check before sleep is required for out-of-GVL ruby_waitpid_all
to function properly when setting waitpid_state.ret
Now that ubf_select can be called by the gvl.timer thread
without recursive locking gvl.lock, we can safely use
rb_threadptr_interrupt to deal with waking up sleeping
processes,
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
It is identical to do_waitpid, and the win32 version will not
be needed for MJIT (since win32 does not suffer from the
waitpid(-1, ...) conflict where waits can get stolen.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64541 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This re-reverts commit r64447.
The issue was machine side problem.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64493 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* process.c (ruby_waitpid_all): nothing to do unless SIGCHLD is
available.
* signal.c (ruby_nocldwait): used only if SIGCHLD is available.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64407 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Arbitrarily closing file descriptors on exec breaks use cases
where a Ruby process sets up a descriptor for non-Ruby children
to use. For example, the "rake foo" target may spawn any number
of subprocesses (Ruby or not) which depends on parsing the "FOO"
environment variable for out_fd:99 and writing to foo.out
FOO=out_fd:99 rake foo 99>>foo.out
Unfortunately, this introduced one incompatibility in
test/lib/test/unit.rb and it now requires explicitly setting
IO#close_on_exec=true
[ruby-core:88007] [Misc #14907]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64399 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
We do not need to rely on SIGVTALRM for non-sighandler wakeups.
This will reduce spurious wakeups in cases where sigwait_fd
is not grabbed again, soon.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64389 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This reverts commit 194a6a2c68 (r64203).
Race conditions which caused the original reversion will be fixed
in the subsequent commit.
[ruby-core:88360] [Misc #14937]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64352 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
getgroups(2) may return a GID list that includes duplicated GIDs.
The behavior is totaly depends on what OS is used.
This commit fixes the example of Process.groups so that the example
is independent of this OS-dependent features.
Additonaly, this commit adds the description of such system-dependent
characteristics of Process.groups.
[ruby-dev:50603] [Bug #14969]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64265 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
by sharing it with vm.c in internal.h.
vm.c: ditto
internal.h: ditto
mjit.h: share more.
mjit.c: make sure the third arguemnt is not used
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64253 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
w->cond may be changed without our knowledge in waitpid_nogvl
without th->interrupt_lock
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64201 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Once a thread has acquired sigwait_fd, hold onto it until
waitpid is complete. This prevents unnecessary migration
and atomic operations.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64200 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
We don't use pthreads cancellation ourselves and it's painful to
use correctly. Any cancelled threads would break
vm->living_threads, GVL, thread_sync.c, autoload, etc...
So don't bother caring; because we can't stop rogue extensions
from completely breaking the VM in other ways, either.
[ruby-core:88282] [Misc #14962]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64197 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
We see several occurrence of "diagnostic push/pop" so why not
make them macros. Tested on GCC8 / Clang 6.
Note that ruby.h is intentionally left untouched because we don't
want to introduce new public macros.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64118 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
We reuse sleep_cond for waitpid notifications as well as GVL
waiting. So we must take care to not hold onto sleep_cond
when we try to reacquire GVL.
[ruby-core:88183]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
To reduce resource use and reduce CI failure; remove
timer-thread. Single-threaded Ruby processes (including forked
children) will never see extra thread overhead. This prevents
glibc and jemalloc from going into multi-threaded mode and
initializing locks or causing fragmentation via arena explosion.
The GVL is implements its own wait-queue as a ccan/list to
permit controlling wakeup order. Timeslice under contention is
handled by a designated timer thread (similar to choosing a
"patrol_thread" for current deadlock checking).
There is only one self-pipe, now, as wakeups for timeslice are
done independently using condition variables. This reduces FD
pressure slightly.
Signal handling is handled directly by a Ruby Thread (instead
of timer-thread) by exposing signal self-pipe to callers of
rb_thread_fd_select, native_sleep, rb_wait_for_single_fd, etc...
Acquiring, using, and releasing the self-pipe is exposed via 4
new internal functions:
1) rb_sigwait_fd_get - exclusively acquire timer_thread_pipe.normal[0]
2) rb_sigwait_fd_sleep - sleep and wait for signal (and no other FDs)
3) rb_sigwait_fd_put - release acquired result from rb_sigwait_fd_get
4) rb_sigwait_fd_migrate - migrate signal handling to another thread
after calling rb_sigwait_fd_put.
rb_sigwait_fd_migrate is necessary for waitpid callers because
only one thread can wait on self-pipe at a time, otherwise a
deadlock will occur if threads fight over the self-pipe.
TRAP_INTERRUPT_MASK is now set for the main thread directly in
signal handler via rb_thread_wakeup_timer_thread.
Originally, I wanted to use POSIX timers
(timer_create/timer_settime) for this. Unfortunately, this
proved unfeasible as Mutex#sleep resumes on spurious wakeups and
test/thread/test_cv.rb::test_condvar_timed_wait failed. Using
pthread_sigmask to mask out SIGVTALRM fixed that test, but
test/fiddle/test_function.rb::test_nogvl_poll proved there'd be
some unavoidable (and frequent) incompatibilities from that
approach.
Finally, this allows us to drop thread_destruct_lock and
interrupt current ec directly.
We don't need to rely on vm->thread_destruct_lock or a coherent
vm->running_thread on any platform. Separate timer-thread for
time slice and signal handling is relegated to thread_win32.c,
now.
[ruby-core:88088] [Misc #14937]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64107 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* process.c (before_fork_ruby, after_fork_ruby): used only if fork()
or daemon() is available.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64065 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
http://ci.rvm.jp/results/trunk-asserts-nopara@silicon-docker/1149270
```
/home/ko1/ruby/src/trunk-asserts-nopara/process.c: In function 'assert_close_on_exec':
/home/ko1/ruby/src/trunk-asserts-nopara/process.c:298:9: warning: ignoring return value of 'write', declared with attribute warn_unused_result [-Wunused-result]
(void)write(2, m, sizeof(m) - 1);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```
workaround from https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425#c34
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64029 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* include/ruby/ruby.h (UNREACHABLE_RETURN): UNREACHABLE at the end
of non-void functions.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64025 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
There's actually no need to close the pipes used by the
sleepy timer thread before forking, only to stop the timer
thread itself.
Instead, we only close the parent pipes in the child process,
either via close-on-exec flag or when reinitializing the timer
thread.
This change will be necessary when we allow
rb_wait_for_single_fd and rb_thread_fd_select to wait on the
timer_thread_pipe.normal[0] directly and eliminate timer thread.
I don't anticipate compatibility problems with this change
alone.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63960 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
We need to preserve "IGNORE" behavior from Ruby 2.5 and earlier.
We can't rely on SA_NOCLDWAIT any more, since we always need
system() and MJIT to work; so we fake that behavior using
dedicated reaper (currently in timer-thread).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63879 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Non-parallel "make test-spec" caused
spec/ruby/core/process/wait2_spec.rb failures because mspec
uses "exec" in single-process mode, so there's no chance
the post-exec state could know about the MJIT child process
from its pre-exec state.
[ruby-core:87846] [Bug #14867]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63877 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Reading win32/win32.c waitpid implementation, maybe waitpid(-1, ...)
on that platform will never conflict with mjit use of waitpid.
In any case, I've added WAITPID_USE_SIGCHLD macro to vm_core.h
so it can be easy for Linux/BSD users to test (hopefully!)
win32-compatible code.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63855 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
The change is unstable on Windows. Please re-commit it when it correctly
supports Windows.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63852 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
For systems with lossy SIGCHLD, an infinitely sleeping timer
thread needs to be aware of rb_waitpid callers in the first
place before it can check and reset polling status.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63829 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Basically in win32, mjit.c seems to work directly on spawnvp
result while normal Ruby code wraps process handles to look
like *nix PIDs. I'm only guessing, here...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63797 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Some systems lack SIGCHLD or have incomplete SIGCHLD
implementations. So enable polling mode for them.
[ruby-core:87705] [Bug #14867]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63795 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
It's a bit redundant, but we optimize for platforms with
SIGCHLD, not without.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63790 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
We may be interrupted by another thread after setting ubf,
but before we re-acquire interrupt_lock again to sleep on
w->cond.
This should fix test_wait_interrupt in test/ruby/test_process.rb
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63789 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
It is possible to have both MJIT and normal child processes
alive, so we cannot set ECHILD based on such a guess. We can
still elide waitpid(PID <= 0) calls if we have callers in
vm->waiting_pids, however.
For specs, ensure Process.waitall does not leak MJIT
PIDs to Rubyspace.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63764 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Use a global SIGCHLD handler to guard all callers of rb_waitpid.
To work safely with multi-threaded programs, we introduce a
VM-wide waitpid_lock to be acquired BEFORE fork/vfork spawns the
process. This is to be combined with the new ruby_waitpid_locked
function used by mjit.c in a non-Ruby thread.
Ruby-level SIGCHLD handlers registered with Signal.trap(:CHLD)
continues to work as before and there should be no regressions
in any existing use cases.
Splitting the wait queues for PID > 0 and groups (PID <= 0)
ensures we favor PID > 0 callers.
The disabling of SIGCHLD in rb_f_system is longer necessary,
as we use deferred signal handling and no longer make ANY
blocking waitpid syscalls in other threads which could "beat"
the waitpid call made by rb_f_system.
We prevent SIGCHLD from firing in normal Ruby Threads and only
enable it in the timer-thread, to prevent spurious wakeups
from in test/-ext-/gvl/test_last_thread.rb with MJIT enabled.
I've tried to guard as much of the code for RUBY_SIGCHLD==0
using C "if" statements rather than CPP "#if" so to reduce
the likelyhood of portability problems as the compiler will
see more code.
We also work to suppress false-positives from
Process.wait(-1, Process::WNOHANG) to quiets warnings from
spec/ruby/core/process/wait2_spec.rb with MJIT enabled.
Lastly, we must implement rb_grantpt for ext/pty. We need a
MJIT-compatible way of supporting grantpt(3) which may spawn
the `pt_chown' binary and call waitpid(2) on it.
[ruby-core:87605] [Ruby trunk Bug#14867]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63758 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
We must block signals before stopping timer-thread, otherwise
signal handing may be delayed until (and if) another signal
is received after timer-thread is restarted.
[ruby-core:87622] [Bug #14868] [Bug #13916]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63741 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Improves readability to me, and there's no point in using
macros for this with decent compilers.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63739 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* configure.ac: clock_gettime or gettimeofday must exist.
* process.c (rb_clock_gettime): prefer clock_gettime over
gettimeofday, as the latter is obsolete in SUSv4.
* random.c (fill_random_seed): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63663 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit eliminates (char **)RSTRING_PTR(...) like usages.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63414 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* gc.c (rb_alloc_tmp_buffer_with_count): keep the order; allocate
an empty imemo first then xmalloc, to get rid of potential
memory leak when allocation imemo failed.
* parse.y (rb_parser_malloc, rb_parser_calloc, rb_parser_realloc):
ditto.
* process.c (rb_execarg_allocate_dup2_tmpbuf): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63385 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Don't abuse struct RString to hold arbitrary memory region.
Thanks to @mame we now have rb_imemo_alloc_auto_free_pointer
so use it instead.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63373 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
rb_thread_sleep's argument is int, while rb_protect expects the function
to take VALUE. Depending on ABI this could be a problem.
We should wrap rb_thread_sleep here.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63339 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
`rb_str_append` may trigger GC, and in that case eargp might be GCed.
Probably for protecting it, `RB_GC_GUARD(execarg_obj)` can be seen in
other places.
Hoping to fix:
http://ci.rvm.jp/results/trunk_gcc5@silicon-docker/569818
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62570 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* process.c (rb_exec_fillarg): share subsequence of argv_buf for
command_name, and copy the encoding from the command string.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62175 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
of `system` with `exception: true` like `Process::Status#inspect`
[Feature #14386] [ruby-core:85013]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62158 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Needlessly exporting can reduce performance locally and increase
binary size.
Increasing the footprint of our C-API larger is also detrimental
to our development as it encourages tighter coupling with our
internals; making it harder for us to preserve compatibility.
If some parts of the core codebase needs access to globals,
internal.h should be used instead of anything in include/ruby/*.
"Urabe, Shyouhei" <shyouhei@ruby-lang.org> wrote:
> On Thu, Jan 18, 2018 at 7:33 PM, Eric Wong <normalperson@yhbt.net> wrote:
> > shyouhei@ruby-lang.org wrote:
> >> https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=61908
> >>
> >> export rb_mFConst
> >
> > Why are we exporting all these and making the public C-API bigger?
> > If anything, we should make these static. Thanks.
>
> No concrete reason, except they have already been externed in 2.5.
> These variables had lacked declarations so far, which resulted in their
> visibility to be that of extern. The commit is just confirming the status quo.
>
> I'm not against to turn them into static.
This reverts changes from r61910, r61909, r61908, r61907, and r61906.
* transcode.c (rb_eUndefinedConversionError): make static
(rb_eInvalidByteSequenceError): ditto
(rb_eConverterNotFoundError): ditto
* process.c (rb_mProcGID, rb_mProcUid, rb_mProcID_Syscall): ditto
* file.c (rb_mFConst): ditto
* error.c (rb_mWarning, rb_cWarningBuffer): ditto
* enumerator.c (rb_cLazy): ditto
[Misc #14381]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62029 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
POSIX only defines mode_t to be "an integer typea", and in fact
MacOS defines it to be uint16_t. We didn't have NUM2USHORT before
so it did not make sense but now that we have it. Why not check
apptopriately.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61950 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* process.c (get_clk_tck): prefer CLK_TCK over older HZ, next to
_SC_CLK_TCK.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61888 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* process.c (proc_s_last_status): add Process.last_status
[ruby-core:83514] [Feature #14043]
* test/ruby/test_process.rb (test_last_status): add a test case for
Process.last_status.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61143 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* eval_error.c (rb_threadptr_error_print): renamed to
rb_ec_error_print() and it accepts `ec`.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60545 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
to represent execution context [Feature #14038]
* vm_core.h (rb_thread_t): rb_thread_t::ec is now a pointer.
There are many code using `th` to represent execution context
(such as cfp, VM stack and so on). To access `ec`, they need to
use `th->ec->...` (adding one indirection) so that we need to
replace them by passing `ec` instead of `th`.
* vm_core.h (GET_EC()): introduced to access current ec. Also
remove `ruby_current_thread` global variable.
* cont.c (rb_context_t): introduce rb_context_t::thread_ptr instead of
rb_context_t::thread_value.
* cont.c (ec_set_vm_stack): added to update vm_stack explicitly.
* cont.c (ec_switch): added to switch ec explicitly.
* cont.c (rb_fiber_close): added to terminate fibers explicitly.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60440 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* array.c (rb_to_array_type): make public to share common code
internally.
* hash.c (rb_to_hash_type): make public to share common code
internally.
* symbol.c (rb_to_symbol_type): make public to share common code
internally.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60438 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Because NaCl and PNaCl are already sunset status.
see https://bugs.chromium.org/p/chromium/issues/detail?id=239656#c160
configure.ac: Patch for this file was provided by @nobu.
[Feature #14041][ruby-core:83497][fix GH-1726]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60374 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
As with forking for execve(2) in `spawn', we must block signals
to ensure they are handled correctly in a freshly `fork'-ed child.
* process.c (retry_fork_ruby): block/unblock signals around fork
(rb_fork_ruby): re-enable signals in forked child
* test/ruby/test_process.rb (test_forked_child_signal): new test
[ruby-core:82883] [Bug #13916]
Thanks to Russell Davis for the bug report and test case.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59975 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* process.c (rb_execarg_addopt_rlimit): hoist out of rb_execarg_addopt
(rlimit_type_by_sym): new wrapper for dynamic symbol
(rb_execarg_addopt): check for dsym via rlimit_type_by_sym
* test/ruby/test_process.rb (test_execopts_rlimit): check dsym w/o pindown
Add extra check for bogus rlimit args, too.
[ruby-core:82033] [Bug #13744]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59322 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm_core.h (rb_thread_t): move several fields which are copied at cont.c
to rb_execution_context_t.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59177 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
To convert the object implicitly, it has had two parts in convert_type() which are
1. lookink up the method's id
2. calling the method
Seems that strncmp() and strcmp() in convert_type() are slightly heavy to look up
the method's id for type conversion.
This patch will add and use internal APIs (rb_convert_type_with_id, rb_check_convert_type_with_id)
to call the method without looking up the method's id when convert the object.
Array#flatten -> 19 % up
Array#+ -> 3 % up
[ruby-dev:50024] [Bug #13341] [Fix GH-1537]
### Before
Array#flatten 104.119k (± 1.1%) i/s - 525.690k in 5.049517s
Array#+ 1.993M (± 1.8%) i/s - 10.010M in 5.024258s
### After
Array#flatten 124.005k (± 1.0%) i/s - 624.240k in 5.034477s
Array#+ 2.058M (± 4.8%) i/s - 10.302M in 5.019328s
### Test Code
require 'benchmark/ips'
class Foo
def to_ary
[1,2,3]
end
end
Benchmark.ips do |x|
ary = []
100.times { |i| ary << i }
array = [ary]
x.report "Array#flatten" do |i|
i.times { array.flatten }
end
x.report "Array#+" do |i|
obj = Foo.new
i.times { array + obj }
end
end
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58978 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
if getrusage(2) is available, to improve precision of Process.times and
its user like lib/benchmark.rb.
On macOS, since getrusage(2) has better precision than times(3),
they are much improved like:
* Before
Process.times
=> #<struct Process::Tms utime=0.56, stime=0.35, cutime=0.04, cstime=0.03>
puts Benchmark.measure { "a" * 1_000_000_000 }
0.340000 0.310000 0.650000 ( 0.674025)
* After
Process.times
=> #<struct Process::Tms utime=0.561899, stime=0.35076, cutime=0.046483, cstime=0.038929>
puts Benchmark.measure { "a" * 1_000_000_000 }
0.343223 0.310037 0.653260 ( 0.674025)
On Linux, since struct rusage from getrusage(2) is used instead of struct tms
from times(2), they are slightly improved like:
* Before
Process.times
=> #<struct Process::Tms utime=0.43, stime=0.11, cutime=0.0, cstime=0.0>
puts Benchmark.measure { "a" * 1_000_000_000 }
0.120000 0.040000 0.170000 ( 0.171621)
* After
Process.times
=> #<struct Process::Tms utime=0.432, stime=0.116, cutime=0.0, cstime=0.0>
puts Benchmark.measure { "a" * 1_000_000_000 }
0.124000 0.048000 0.172000 ( 0.171621)
[ruby-dev:49471] [Feature #11952]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58935 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* process.c (obj2uid, obj2gid): check the error number returned by
`getpwnam_r()` and `getgrnam_r()`, instead of `errno`.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58662 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* process.c (obj2uid, obj2gid): use temporary string as the buffer
instead of `rb_alloc_tmp_buffer`, which is `NODE_ALLOCA` since
r51492. [ruby-core:81084] [Bug #13554]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58658 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
We already check for __builtin_mul_overflow in configure but never
actually referred it before. Why not call it if available, because
that should render supposedly-optimial assembly outputs.
Optionally if __builtin_mul_overflow_p is available, which is the case
for recent GCC, use that to detect fixnum overflow. This is much
faster than the previous. On my machine generated assembly of
numeric.c:int_pow reduces from 480 to 448 bytes, according to nm(1).
Also on my machine, following script boosts from 7.819 to 6.929 sec.
time ./miniruby -e 'i=0; while i < 30_000_000 do i += 1; 7 ** 23; end'
Signed-off-by: Urabe, Shyouhei <shyouhei@ruby-lang.org>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57784 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
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
[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
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
* 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
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
* 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
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
* 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
* 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
* 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
* 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
* 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
* 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
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
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
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
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
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
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
* 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): 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 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
* 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
* 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
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
* 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 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 (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
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
* 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.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 (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 (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 (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