-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Set sync
or flush_on_newline
for standard I/O on Windows.
#9207
Conversation
Yes, it is better to move the code as you described. |
151a184
to
2e1a236
Compare
If starndard I/O is a handle to the console, set `sync` to true. Otherwise, set `flush_on_newline` to true as described in STDOUT and STDERR docs.
2e1a236
to
e43943a
Compare
Add a comment as requested by @straight-shoota here. |
This should be merged as separate commits btw. |
Could you explain more specific? I cannot understand your request. |
Sorry for confusion :( |
Sorry, we can't do that any more, @waj decided everything had to be squashed. |
Yeah, how lovely... |
Please let's not say X decided something. Many of us agree that squashing is fine because you can always go to the PR to see the commit history. @oprypin do you think it would be fine to squash this anyway? In my experience whenever I ended up using blame and in a single commit, I navigated to the PR anyway to understand the overall context. |
I would be fine with always squashing, and announcing that that is the case, then people won't have any reason to force-push into the PR branch. Otherwise we're getting the worst of both worlds. |
I've had an idea for a solution which would make everyone happy for a few years, but unfortunately it requires writing code and starting a new project is hard to justify... I apologise for being ratty this morning, I think I might need to take a break from Crystal... |
I think that's another benefit of squashing: PR authors don't need to care about keeping a clean commit history. That should speed up contributions. |
This PR sets
sync
orflush_on_newline
for standard I/O on Windows as on Unix.This uses GetConsoleMode, which succeeds only when the handle is to the console.
I tested it by the code in #9149 (comment). Without this PR, the benchmark results are displayed on process exit. With this PR, they are displayed as on Unix.
I want to hear opinions. Is it better to move win32 and unix code in
IO::FileDescriptor.from_stdio
tocrystal/system/win32/file_descriptor.cr
andcrystal/system/unix/file_descriptor.cr
respectively?