ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: "nobu (Nobuyoshi Nakada)" <noreply@ruby-lang.org>
To: ruby-core@ruby-lang.org
Subject: [ruby-core:105591] [Ruby master Bug#18244] Unexpected errors output order
Date: Thu, 07 Oct 2021 15:26:28 +0000 (UTC)	[thread overview]
Message-ID: <redmine.journal-94060.20211007152628.25466@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-18244.20211007055809.25466@ruby-lang.org

Issue #18244 has been updated by nobu (Nobuyoshi Nakada).


It sounds hard anyway regardless `stderr` buffering.
Why mixing `stdout` and `stderr`?

https://github.com/ruby/ruby/pull/4944

----------------------------------------
Bug #18244: Unexpected errors output order
https://bugs.ruby-lang.org/issues/18244#change-94060

* Author: inversion (Yura Babak)
* Status: Feedback
* Priority: Normal
* ruby -v: Ruby v3.0.2.107 (2021-07-07) [x64-mingw32]
* Backport: 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------
Having this code:
```ruby
# $stderr.sync = false
warn 'warn'
$stderr.puts 'err'
fail
```
When I run it like this `ruby test.rb 2>err.log`, output is ok:
```
warn
err
test.rb:3:in `<main>': unhandled exception
```

But when I uncomment the first line — the output is different:
```
warn
test.rb:3:in `<main>': unhandled exception
err
```
Why buffered output to the `$stderr` redirected to file has the **wrong order**?
If we do not redirect to the file — the order is ok (exception is the last line of the output).

Checked platforms:
`Windows10: Ruby v3.0.2.107 (2021-07-07) [x64-mingw32]`
`Linux: Ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-linux]`



-- 
https://bugs.ruby-lang.org/

  parent reply	other threads:[~2021-10-07 15:26 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-07  5:58 [ruby-core:105586] [Ruby master Bug#18244] Unexpected errors output order inversion (Yura Babak)
2021-10-07 13:06 ` [ruby-core:105589] " nobu (Nobuyoshi Nakada)
2021-10-07 14:12 ` [ruby-core:105590] " inversion (Yura Babak)
2021-10-07 15:26 ` nobu (Nobuyoshi Nakada) [this message]
2021-10-07 20:00 ` [ruby-core:105596] " inversion (Yura Babak)
2021-10-07 23:58 ` [ruby-core:105601] " Eregon (Benoit Daloze)
2021-10-08  5:57 ` [ruby-core:105604] " inversion (Yura Babak)
2021-10-08 10:48 ` [ruby-core:105606] " Eregon (Benoit Daloze)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.journal-94060.20211007152628.25466@ruby-lang.org \
    --to=ruby-core@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).