summaryrefslogtreecommitdiff
path: root/ext/pty/pty.c
AgeCommit message (Collapse)Author
13 days[pty] Fix `ptsname_r` fallbackNobuyoshi Nakada
If `posix_openpt` is available, also `ptsname` should be available.
2024-04-11[pty] Support `ptsname_r` of glibcNobuyoshi Nakada
Although glibc `ptsname_r` man page mentions Tru64 and HP-UX, this function appears to be declared obsolete on both.
2024-04-09[pty] Split `chfunc` into functions in stepsNobuyoshi Nakada
- start a new session - obtain the new controlling terminal - drop privileges - finally, `exec`
2024-04-07Fix a typo, missing `P` in `SETPGRP_VOID`Nobuyoshi Nakada
2024-04-04Revert "hijack SIGCHLD handler for internal use"Nobuyoshi Nakada
This reverts commit 054a412d540e7ed2de63d68da753f585ea6616c3. SIGCHLD `waidpid`, `waitpid_lock` and related code, have been removed at ruby/ruby#7527.
2023-12-18[DOC] Show `PTY.getpty` as an alias of `PTY.spawn`Nobuyoshi Nakada
`:nodoc:` directive does not work at method definition in C, and must be at the implementation function. That is, there is no way to make one method visible and another method sharing the implementation invisible at the same time.
2023-06-01Hide the usage of `rb_io_t` where possible. (#7880)Samuel Williams
This retries the compatible parts of the previously reverted PR so we can continue to update related code without breaking backwards compatibility. Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2023-06-01Revert "Hide most of the implementation of `struct rb_io`. (#6511)"NARUSE, Yui
This reverts commit 18e55fc1e1ec20e8f3166e3059e76c885fc9f8f2. fix [Bug #19704] https://bugs.ruby-lang.org/issues/19704 This breaks compatibility for extension libraries. Such changes need a discussion.
2023-05-30Hide most of the implementation of `struct rb_io`. (#6511)Samuel Williams
* Add rb_io_path and rb_io_open_descriptor. * Use rb_io_open_descriptor to create PTY objects * Rename FMODE_PREP -> FMODE_EXTERNAL and expose it FMODE_PREP I believe refers to the concept of a "pre-prepared" file, but FMODE_EXTERNAL is clearer about what the file descriptor represents and aligns with language in the IO::Buffer module. * Ensure that rb_io_open_descriptor closes the FD if it fails If FMODE_EXTERNAL is not set, then it's guaranteed that Ruby will be responsible for closing your file, eventually, if you pass it to rb_io_open_descriptor, even if it raises an exception. * Rename IS_EXTERNAL_FD -> RUBY_IO_EXTERNAL_P * Expose `rb_io_closed_p`. * Add `rb_io_mode` to get IO mode. --------- Co-authored-by: KJ Tsanaktsidis <ktsanaktsidis@zendesk.com> Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2022-09-21getenv: is in stdlib.h卜部昌平
getenv is a very basic function that has been in stdlib.h since ISO/IEC 9899:1990. There is absolutely zero need for us to redeclare. pty.c already includes stdlib.h out of the box so we need nothing. Notes: Merged: https://github.com/ruby/ruby/pull/6358
2022-07-21Expand tabs [ci skip]Takashi Kokubun
[Misc #18891] Notes: Merged: https://github.com/ruby/ruby/pull/6094
2022-04-13Update PTY.spawn's documentStan Lo
Passing the optional env hash to PTY.spawn has been supported for years, but it's never documented. More info: https://bugs.ruby-lang.org/issues/12312 Notes: Merged: https://github.com/ruby/ruby/pull/5786
2022-01-18[Feature #18491] Drop support for HP-UXPeter Zhu
IA64 support was dropped in ticket #15894, so we can drop support for HP-UX. Notes: Merged: https://github.com/ruby/ruby/pull/5457
2021-02-08Revert a part of "[DOC] refined" [ci skip]Nobuyoshi Nakada
This reverts commit 478716f49a19cdd86f629c6a0673c1ff53630c96 partially -- "Removed unnecessary parentheses" part -- because of a lambda, see 9e25eb308d4fae9a10e120c2b4601916cc38336c.
2021-02-07[DOC] refinedNobuyoshi Nakada
* Adjusted indentation in license section, and used "(c)" * Commented out invalid syntax to enable highlighting * Removed unnecessary parentheses
2021-01-05[DOC] Fix grammar: "is same as" -> "is the same as"Marcus Stollsteimer
2020-08-24Update PTY.open documentation to document it yields a single argument [ci skip]Jeremy Evans
For a regular block, accepting two arguments is fine as the array will be autosplatted. However, a lambda that accepts two arguments will not work. We could change the implementation to yield two arguments instead of an array with a single argument, but that would be less backwards compatible. I'm only changing the call-seq to be precise, other examples pass a literal block that accepts two arguments, and I left those alone as that will be the most common usage. Fixes [Bug #17094]
2020-07-28Use https instead of httpKazuhiro NISHIYAMA
2019-12-26decouple internal.h headers卜部昌平
Saves comitters' daily life by avoid #include-ing everything from internal.h to make each file do so instead. This would significantly speed up incremental builds. We take the following inclusion order in this changeset: 1. "ruby/config.h", where _GNU_SOURCE is defined (must be the very first thing among everything). 2. RUBY_EXTCONF_H if any. 3. Standard C headers, sorted alphabetically. 4. Other system headers, maybe guarded by #ifdef 5. Everything else, sorted alphabetically. Exceptions are those win32-related headers, which tend not be self- containing (headers have inclusion order dependencies). Notes: Merged: https://github.com/ruby/ruby/pull/2711
2019-08-27rb_ensure now free from ANYARGS卜部昌平
After 5e86b005c0f2ef30df2f9906c7e2f3abefe286a2, I now think ANYARGS is dangerous and should be extinct. This commit deletes ANYARGS from rb_ensure, which also revealed many arity / type mismatches.
2019-03-06Fix PTY.open on OpenBSD [Bug #15607]naruse
From: Jeremy Evans <code@jeremyevans.net> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67183 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-16[doc] Fix grammar typo in Pty_init() docstring [ci skip]k0kubun
[Fix GH-2014] From: Olle Jonsson <olle.jonsson@gmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65758 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-18pty.c: typonobu
* 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
2018-09-18pty.c: more difensivenobu
* 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
2018-07-24UNREACHABLE_RETURNnobu
* 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
2018-07-05unrevert r63852 but keep SIGCHLD path disabled for win32normal
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
2018-07-04Revert r63758 and related commitsnaruse
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
2018-06-27hijack SIGCHLD handler for internal usenormal
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
2018-05-23ext/pty/pty.c: I_FIND before I_PUSH if possiblengoto
* 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
2018-01-24process.c: add :exception option to Kernel.#systemk0kubun
to raise error when it fails. [Feature 14386] [GH-1795] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62025 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-09Include ruby/{io,encoding}.h before internal.hkazu
because of r61712 and r61713 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61725 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-27pty.c: shrink repeated device namesnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60044 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-30pty.c: dry upnobu
* ext/pty/pty.c (establishShell): gather initializations by the default shell path. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54823 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-30pty.c: user shellnobu
* 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
2016-04-30pty.c: portabilitiesnobu
* 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
2015-12-18* ext/pty/pty.c: fix double words typo.hsbt
[ci skip][fix GH-1157] Patch by @jwworth git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53176 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-19pty.c: fix example typo [ci skip]nobu
* 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
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
2015-02-27* ext/pty/pty.c: AIX supports autopush. Patch by Perry Smith ↵odaira
[ruby-core:58539] [Bug #9144] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49776 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-11[DOC]akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49213 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-15* internal.h: Include ruby.h and ruby/encoding.h to beakr
includable without prior inclusion. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-10ruby/io.h: deprecate old macrosnobu
* 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
2014-10-04* ext/win32ole/win32ole.c: [DOC] Fix typo in :nodoc: reported byzzak
@windwiny to [Fix GH-705] https://github.com/ruby/ruby/pull/705 * ext/pty/pty.c: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47783 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-30protoize no-arguments functionsnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47744 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-26pty.c: do nothing if terminated alreadynobu
* 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
2014-01-12ext: use rb_sprintf() and rb_vsprintf() with PRIsVALUEnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44572 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-05pty.c: check error of seteuidnobu
* ext/pty/pty.c (chfunc): check error of seteuid and return error message, to suppress unused-value warning. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43538 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-25* ext/pty/pty.c (get_device_once): FreeBSD 10-current and 9-stablenaruse
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
2013-03-21use rb_pid_t instead of pid_t.kazu
* process.c (rb_execarg_addopt, run_exec_pgroup): use rb_pid_t instead of pid_t. * ext/pty/pty.c (raise_from_check, pty_check): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39868 b2dd03c8-39d4-4d8f-98ff-823fe69b080e