[win32][patch] Detect mintty with win32 console version

109 views
Skip to first unread message

Ken Takata

unread,
Jun 22, 2016, 8:56:50 AM6/22/16
to vim_dev
Hi,

When win32 vim.exe is executed on mintty (which is the default terminal emulator
on Cygwin/MSYS2), vim.exe hangs up because mintty (more precisely, cygwin pty)
is not compatible with Command Prompt.
Cygwin and MSYS2 have own versions of Vim, so people should use these versions
on mintty. However if someone runs win32 vim.exe on mintty by mistake, the
problem occurs. This is very bad user experience. Hang-up should be avoided.

I propose a patch to detect mintty with the win32 version of vim.
When the vim.exe detects mintty, it outputs an error message and exits soon
unless the option --not-a-term is specified.

https://bitbucket.org/k_takata/vim-ktakata-mq/src/tip/add-check-for-cygwin-pty.patch

This uses a detection routine from my small project:
https://github.com/k-takata/ptycheck
iscygpty.{c,h} are intended to be used as a library.
(I created this mainly for Vim, but not limited to Vim. So it is MIT/Vim
dual-licensed.)

This uses GetFileInformationByHandleEx() to detect mintty. This API is rather
new (introduced in Vista), so this patch requires VC2008 (or newer MinGW).
If VC2005 or earlier are used, the detection is disabled.

WinXP doesn't have GetFileInformationByHandleEx() natively, so the detection
doesn't work on XP, but the vim.exe can run on XP because dynamic loading is
used. (Actually, if "Win32 FileID API Library" is linked, the API can be used
also on XP, but the library is no more available from Microsoft website.)

What do you think? Comments are welcome.

Regards,
Ken Takata

Bram Moolenaar

unread,
Jun 26, 2016, 2:38:10 PM6/26/16
to Ken Takata, vim_dev
VC 2008 is the recommended compiler for the widest Windows OS coverage.
So that is fine.

Let's include this and see if someone has a problem with it.

--
hundred-and-one symptoms of being an internet addict:
142. You dream about creating the world's greatest web site.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages