mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Reuse ractor stderr
This commit is contained in:
parent
a706c09fa6
commit
606e785fa8
1 changed files with 9 additions and 7 deletions
16
io.c
16
io.c
|
@ -8168,15 +8168,16 @@ rb_obj_display(int argc, VALUE *argv, VALUE self)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
rb_stderr_to_original_p(void)
|
rb_stderr_to_original_p(VALUE err)
|
||||||
{
|
{
|
||||||
return (rb_ractor_stderr() == orig_stderr || RFILE(orig_stderr)->fptr->fd < 0);
|
return (err == orig_stderr || RFILE(orig_stderr)->fptr->fd < 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
rb_write_error2(const char *mesg, long len)
|
rb_write_error2(const char *mesg, long len)
|
||||||
{
|
{
|
||||||
if (rb_stderr_to_original_p()) {
|
VALUE out = rb_ractor_stderr();
|
||||||
|
if (rb_stderr_to_original_p(out)) {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
if (isatty(fileno(stderr))) {
|
if (isatty(fileno(stderr))) {
|
||||||
if (rb_w32_write_console(rb_str_new(mesg, len), fileno(stderr)) > 0) return;
|
if (rb_w32_write_console(rb_str_new(mesg, len), fileno(stderr)) > 0) return;
|
||||||
|
@ -8188,7 +8189,7 @@ rb_write_error2(const char *mesg, long len)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
rb_io_write(rb_ractor_stderr(), rb_str_new(mesg, len));
|
rb_io_write(out, rb_str_new(mesg, len));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8201,8 +8202,9 @@ rb_write_error(const char *mesg)
|
||||||
void
|
void
|
||||||
rb_write_error_str(VALUE mesg)
|
rb_write_error_str(VALUE mesg)
|
||||||
{
|
{
|
||||||
|
VALUE out = rb_ractor_stderr();
|
||||||
/* a stopgap measure for the time being */
|
/* a stopgap measure for the time being */
|
||||||
if (rb_stderr_to_original_p()) {
|
if (rb_stderr_to_original_p(out)) {
|
||||||
size_t len = (size_t)RSTRING_LEN(mesg);
|
size_t len = (size_t)RSTRING_LEN(mesg);
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
if (isatty(fileno(stderr))) {
|
if (isatty(fileno(stderr))) {
|
||||||
|
@ -8216,14 +8218,14 @@ rb_write_error_str(VALUE mesg)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* may unlock GVL, and */
|
/* may unlock GVL, and */
|
||||||
rb_io_write(rb_ractor_stderr(), mesg);
|
rb_io_write(out, mesg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
rb_stderr_tty_p(void)
|
rb_stderr_tty_p(void)
|
||||||
{
|
{
|
||||||
if (rb_stderr_to_original_p())
|
if (rb_stderr_to_original_p(rb_ractor_stderr()))
|
||||||
return isatty(fileno(stderr));
|
return isatty(fileno(stderr));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue