[PATCH] Cygwin: termios: Follow symlink in is_console_app()
Takashi Yano
takashi.yano@nifty.ne.jp
Wed Dec 10 05:38:47 GMT 2025
>From cygwin 3.6.0, WSL cannot start by distribution name such as
debian.exe, which has '.exe' extention but actually is a symlink.
This is because is_console_app () returns false for that symlink.
This patch fixes the issue using PC_SYM_FOLLOW option in path_conv.
Fixes: a commit between cygwin 3.5.7 and 3.6.0
Reviewed-by:
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
---
winsup/cygwin/fhandler/termios.cc | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/winsup/cygwin/fhandler/termios.cc b/winsup/cygwin/fhandler/termios.cc
index 19d6220bc..1026b6969 100644
--- a/winsup/cygwin/fhandler/termios.cc
+++ b/winsup/cygwin/fhandler/termios.cc
@@ -704,8 +704,14 @@ fhandler_termios::fstat (struct stat *buf)
static bool
is_console_app (const WCHAR *filename)
{
+ UNICODE_STRING upath;
+ RtlInitCountedUnicodeString (&upath, filename,
+ wcslen (filename) * sizeof (WCHAR));
+ path_conv pc (&upath);
+ WCHAR *native_path = pc.get_nt_native_path ()->Buffer;
+
HANDLE h;
- h = CreateFileW (filename, GENERIC_READ, FILE_SHARE_READ,
+ h = CreateFileW (native_path, GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, 0, NULL);
char buf[1024];
DWORD n;
--
2.51.0
More information about the Cygwin-patches
mailing list