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

Improve isatty() Windows implementation with Cygwin/Mingw pseudo terminals #11

Closed
hboutemy opened this issue Sep 25, 2017 · 2 comments
Closed

Comments

@hboutemy
Copy link
Collaborator

hboutemy commented Sep 25, 2017

as seen in Jansi issue fusesource/jansi#94, Cygwin and Mingw use pseudo terminals, not real terminals
Then isatty() does not detect the pseudo-terminal
Git has a workaround: git/git@8692483

        /* get pipe name */
 	if (!NT_SUCCESS(NtQueryObject(h, ObjectNameInformation,
 			buffer, sizeof(buffer) - 2, &result)))
 		return;
 	name = nameinfo->Name.Buffer;
 	name[nameinfo->Name.Length] = 0;
 
	/*
	 * Check if this could be a MSYS2 pty pipe ('msys-XXXX-ptyN-XX')
	 * or a cygwin pty pipe ('cygwin-XXXX-ptyN-XX')
	 */
	if ((!wcsstr(name, L"msys-") && !wcsstr(name, L"cygwin-")) ||
			!wcsstr(name, L"-pty"))
		return;

This code should be added to Jansi native isatty() implementation for Windows to properly detect (pseudo)terminal with Cygwin and Mingw

@gnodet gnodet closed this as completed in 461068c Feb 1, 2018
@gnodet gnodet reopened this Feb 1, 2018
@gnodet
Copy link
Member

gnodet commented Feb 1, 2018

The code builds, but it does not seem to give the expected results.
When I execute the CLibrary.isatty(0) or CLibrary.isatty(1) under cygwin, both returns 0.

@hboutemy
Copy link
Collaborator Author

hboutemy commented Feb 1, 2018

did you try to get the value of the terminal name?
this is really the current code in git: https://github.com/git/git/blob/master/compat/winansi.c#L537

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