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

wslbridge hangs when running elevated and non-elevated WSL instances simultaneously #13

Closed
rprichard opened this issue May 17, 2017 · 7 comments

Comments

@rprichard
Copy link
Owner

See mintty/wsltty#43 (comment).

wslbridge won't work in this situation, but it should try to fail gracefully.

@rprichard
Copy link
Owner Author

Survey of Windows versions:
10586: no WSL feature
14393: simultaneous elevated and non-elevated instances allowed, redirecting stdout is not (Error: 0x80070057)
15063: simultaneous elevated and non-elevated instances not allowed, redirecting stdout is

I guess wslbridge can detect 15063 and up (how?), then redirect stdout to a pipe and detect the error.

@mintty
Copy link

mintty commented May 17, 2017

  FILE * pf = popen("cmd /C ver", "r");
  fgets(line, sizeof line, pf)); fgets(line, sizeof line, pf));

@rprichard
Copy link
Owner Author

 FILE * pf = popen("cmd /C ver", "r");
 fgets(line, sizeof line, pf)); fgets(line, sizeof line, pf));

Maybe. I wonder about: (a) performance, (b) security/reliability, and (c) localization. I think I'd prefer if it queried the System32 directory and invoked cmd.exe without doing a PATH lookup. I'm guessing localization isn't an issue, because the string is "\nMicrosoft Windows [Version 10.0.15063]\n". Maybe the Version part is translated, but I suppose it'd be possible to look for a trailing version-and-right-bracket at the end of the second line. I benchmarked it in my Win10 VM, and it usually took ~11ms on repeated runs, but it sometimes took up to ~30ms.

I tried GetVersionEx, and it worked fine (e.g. returned the 15063 dwBuildNumber) with fully-updated MSYS2 and Cygwin compilers. I guess they automatically provide the necessary manifest, so I'm currently preferring this approach.

@rprichard
Copy link
Owner Author

If the EXE had no manifest at all, then GetVersionEx would return Windows 8. Windows 8 doesn't have WSL, so the program could abort.

@mintty
Copy link

mintty commented May 31, 2017

Wow! What a tremendous effort to capture an error message. Thanks a lot for committing this.

@mintty
Copy link

mintty commented Jun 22, 2017

@rprichard, can you make this a release, please? So I can again refer to a well-defined version from wsltty?

@rprichard
Copy link
Owner Author

Ok, the fix for this issue is now released in version 0.2.2.

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

No branches or pull requests

2 participants