Project

General

Profile

Actions

Bug #18244

closed

Unexpected errors output order

Added by inversion (Yura Babak) about 3 years ago. Updated almost 3 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
Ruby v3.0.2.107 (2021-07-07) [x64-mingw32]
[ruby-core:105586]

Description

Having this code:

# $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]

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0