* ext/pty/pty.c (chfunc): fix a typo of an operator. pointed out by
jaruga (Jun Aruga) at [ruby-core:89058]. [Bug #15116]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64771 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ext/pty/pty.c (chfunc): should not close the slave fd if it is 0..2.
[ruby-core:89043] [Bug #15116]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64766 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
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
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
* ext/pty/pty.c: Check whether each STREAMS module is already pushed
or not by using I_FIND ioctl call, before pushing it by using I_PUSH.
Solved test failure on Solaris. On a Solaris 10 machine, ioctl I_PUSH
"ldterm" twice was the cause of duplicated "\r".
[Bug #14786] [ruby-dev:50552]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63495 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ext/pty/pty.c (establishShell): honor USER environment variable
and login name over uid, one pid can be shared by some login
names.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54822 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ext/pty/pty.c (no_mesg): define only if used.
* ext/pty/pty.c (pty_check): some flags may not be defined.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54820 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ext/pty/pty.c: [DOC] fix example typo, an old name at move from
PTY.open. [Fix GH-972]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51297 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
* include/ruby/io.h (rb_io_mode_flags, rb_io_modenum_flags):
deprecate old macros for compatibility for ruby 1.8 and older.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47861 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ext/pty/pty.c (pty_detach_process): if the child process has
terminated already, return immediately without starting a thread
to detach it.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46129 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
added O_CLOEXEC support to posix_openpt, so assume FreeBSD 9.2 or
later supports it.
http://www.freebsd.org/cgi/query-pr.cgi?pr=162374
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40928 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ext/pty/extconf.rb: modify $INCFLAGS to include internal.h
* ext/pty/pty.c: include internal.h.
(chfunc): don't call rb_thread_atfork_before_exec. use
rb_exec_async_signal_safe instead of rb_f_exec.
(establishShell): set up earg. use rb_fork_async_signal_safe
instead of rb_fork_err.
* internal.h (rb_exec_async_signal_safe): declared.
(rb_fork_async_signal_safe): declared.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36002 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* process.c (rb_fork_err): determine status on errors.
* ext/pty/pty.c (establishShell): reraise exception if something
raised during sleep.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35959 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ext/pty/pty.c (establishShell): now needs status to protect from
exceptions in rb_fork_err().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35958 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
for posix_openpt, but FreeBSD 9's posix_openpt doesn't support
O_CLOEXEC and fails if specified.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33668 b2dd03c8-39d4-4d8f-98ff-823fe69b080e