New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stdout/stderr should not be line buffered #948

Closed
ry opened this Issue Oct 9, 2018 · 6 comments

Comments

2 participants
@ry
Copy link
Collaborator

ry commented Oct 9, 2018

we are using tokio-fs's stdout, which writes to std::io::Stdout

Rust's stdout is always line buffered:
https://github.com/rust-lang/rust/blob/e1643a8968753226dab7ab3c9fee826f097550f2/src/libstd/io/stdio.rs#L344-L349
We are not so happy with this behavior and likely want an always unbuffered stdout, as in Node. To support his behavior we will need to refactor the stdout/stderr resources to use a raw file descriptor like this:

use std::os::unix::io::FromRawFd;
let stdout = File::from_raw_fd(1);

this came up in #946

@hayd

This comment has been minimized.

Copy link
Contributor

hayd commented Oct 10, 2018

Is an alternative to flush after each write? Or is the concern that that'd be inefficient?

@ry

This comment has been minimized.

Copy link
Collaborator Author

ry commented Oct 10, 2018

I think line buffered is confusing - and especially so when we don’t even allow directly writing strings - so I’d prefer to not add flush

@hayd

This comment has been minimized.

Copy link
Contributor

hayd commented Oct 10, 2018

I mean, flush in rust after each write (but it's kinda ugly): hayd@db4ca6c

@ry

This comment has been minimized.

Copy link
Collaborator Author

ry commented Oct 11, 2018

@hayd I'd rather not call flush. It seems excessive. Maybe it's a good stopgap solution tho...

@hayd

This comment has been minimized.

Copy link
Contributor

hayd commented Nov 4, 2018

Your PR fs::File::from_std() was included in into tokio-fs-0.1.4 (which deno is using now).

@ry

This comment has been minimized.

Copy link
Collaborator Author

ry commented Nov 23, 2018

I got half way done with this before getting distracted. Will try to fix up in the next few days.
WIP here ry@7560787

@ry ry added this to the v0.3 milestone Nov 25, 2018

This was referenced Dec 15, 2018

@ry ry closed this in #1355 Dec 23, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment