Skip to content
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

Fix #9244 #9251

Merged
merged 1 commit into from
Dec 9, 2014
Merged

Fix #9244 #9251

merged 1 commit into from
Dec 9, 2014

Conversation

twadleigh
Copy link
Contributor

The proper solution will, I'm sure, at least include proper cleanup, but this hack was sufficient to get my simple use case working for me.

@vtjnash
Copy link
Sponsor Member

vtjnash commented Dec 4, 2014

Can you add a comment indicating that the case fall through is intentional?

Otherwise, I don't see any reason not to merge this.

I think you need a dup2 / SetStandardIOHandle call (whatever it's called) also so that it gets setup correctly for any C code being run (such as ios_stderr)

-From my iPhone

@twadleigh
Copy link
Contributor Author

@vtjnash: added the dup2 and comments.

@joa-quim joa-quim mentioned this pull request Dec 5, 2014
@twadleigh twadleigh changed the title WIP: partial fix for #9244, a hack to handle uninitialized stdio. Fix #9244 Dec 5, 2014
@vtjnash
Copy link
Sponsor Member

vtjnash commented Dec 5, 2014

I think you need to call both SetStdHandle and _dup2 on Windows. one to set the handle in the posix/C runtime, and the other to set it in the winapi runtime. plus, you may also need to reassign the stdin/stdout/stderr FILE* handles, for the posix/C runtime. finally, you may need to call AllocConsole(); ShowWindow( GetConsoleWindow(), SW_HIDE ); first, for the winnt host runtime.

Although typical WTF moment of making fixes on windows: the result (of using the C run time from julia) is officially undefined behavior on windows and is subject to change or fail on future versions of windows. but "by coincidence" it will typically work right now. https://support.microsoft.com/kb/105305/en-us?wa=wsignin1.0). That really makes me want to start running, running faster that is.

additional sources:
https://homepage.ntlworld.com/jonathan.deboynepollard/FGA/redirecting-standard-io.html
https://social.msdn.microsoft.com/Forums/vstudio/en-US/a111b4c6-c491-4586-8fcb-2ad67bfbbae8/is-setstdhandlestdoutputhandle-broken-under-windows-7-

@twadleigh
Copy link
Contributor Author

@vtjnash: Maybe before modifying this patch further, we should concoct a test.

Which interfaces would need to be exercised in that test? Do you think it would it be sufficient to test C stdio along with Julia's own I/O?

@vtjnash
Copy link
Sponsor Member

vtjnash commented Dec 5, 2014

Sounds wise. You would need to compile a version of ui/repl.c (aka julia.exe) for win32 (tater than console) and spawn that in the test in such a way that the stdio handles don't get correctly initialized (I think the windows shell API will do this for you if you invoke 'start', see Microsoft support link above)

@JeffBezanson
Copy link
Sponsor Member

I'm going to merge this, since it only affects a case that used to fail anyway.

JeffBezanson added a commit that referenced this pull request Dec 9, 2014
@JeffBezanson JeffBezanson merged commit 918da08 into JuliaLang:master Dec 9, 2014
@JeffBezanson
Copy link
Sponsor Member

I'd like to backport this as well. cc @JuliaBackports

@twadleigh twadleigh deleted the stdio-hack branch December 9, 2014 15:55
twadleigh pushed a commit to twadleigh/julia that referenced this pull request Dec 9, 2014
@ivarne
Copy link
Sponsor Member

ivarne commented Dec 9, 2014

Backporting PR in #9282

JeffBezanson added a commit that referenced this pull request Dec 9, 2014
Backport: Merge pull request #9251 from twadleigh/stdio-hack
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants