Skip to content

Commit a18fe29

Browse files
tyan0dscho
authored andcommitted
Cygwin: termios: Change argument of fhandler_termios::spawn_worker()
This patch changes the argument for passsing a path to an app to fhandler_termios::spawn_worker() from const WCHAR *runpath to path_conv &pc. The purpose of this patch is to prepare for a subsequent patch, that is intended to fix a bug in executing Microsoft Store apps. Reviewed-by: Johannes Schindelin <[email protected]> Signed-off-by: Takashi Yano <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 835bcd9 commit a18fe29

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

winsup/cygwin/fhandler/termios.cc

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -702,13 +702,17 @@ fhandler_termios::fstat (struct stat *buf)
702702
}
703703

704704
static bool
705-
is_console_app (const WCHAR *filename)
705+
is_console_app (path_conv &pc)
706706
{
707-
wchar_t *e = wcsrchr (filename, L'.');
707+
tmp_pathbuf tp;
708+
WCHAR *native_path = tp.w_get ();
709+
pc.get_wide_win32_path (native_path);
710+
711+
wchar_t *e = wcsrchr (native_path, L'.');
708712
if (e && (wcscasecmp (e, L".bat") == 0 || wcscasecmp (e, L".cmd") == 0))
709713
return true;
710714
HANDLE h;
711-
h = CreateFileW (filename, GENERIC_READ, FILE_SHARE_READ,
715+
h = CreateFileW (native_path, GENERIC_READ, FILE_SHARE_READ,
712716
NULL, OPEN_EXISTING, 0, NULL);
713717
if (h == INVALID_HANDLE_VALUE)
714718
return true;
@@ -761,7 +765,7 @@ fhandler_termios::ioctl (unsigned int cmd, void *varg)
761765

762766
void
763767
fhandler_termios::spawn_worker::setup (bool iscygwin, HANDLE h_stdin,
764-
const WCHAR *runpath, bool nopcon,
768+
path_conv &pc, bool nopcon,
765769
bool reset_sendsig,
766770
const WCHAR *envblock)
767771
{
@@ -800,7 +804,7 @@ fhandler_termios::spawn_worker::setup (bool iscygwin, HANDLE h_stdin,
800804
ptys->setup_locale ();
801805
}
802806
}
803-
if (!iscygwin && ptys_primary && is_console_app (runpath))
807+
if (!iscygwin && ptys_primary && is_console_app (pc))
804808
{
805809
if (h_stdin == ptys_primary->get_handle_nat ())
806810
stdin_is_ptys = true;

winsup/cygwin/local_includes/fhandler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2035,7 +2035,7 @@ class fhandler_termios: public fhandler_base
20352035
spawn_worker () :
20362036
ptys_need_cleanup (false), cons_need_cleanup (false),
20372037
stdin_is_ptys (false), ptys_ttyp (NULL) {}
2038-
void setup (bool iscygwin, HANDLE h_stdin, const WCHAR *runpath,
2038+
void setup (bool iscygwin, HANDLE h_stdin, path_conv &pc,
20392039
bool nopcon, bool reset_sendsig, const WCHAR *envblock);
20402040
bool need_cleanup () { return ptys_need_cleanup || cons_need_cleanup; }
20412041
void cleanup ();

winsup/cygwin/spawn.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ child_info_spawn::worker (const char *prog_arg, const char *const *argv,
579579

580580
bool no_pcon = mode != _P_OVERLAY && mode != _P_WAIT;
581581
term_spawn_worker.setup (iscygwin (), handle (fileno_stdin, false),
582-
runpath, no_pcon, reset_sendsig, envblock);
582+
real_path, no_pcon, reset_sendsig, envblock);
583583

584584
/* Set up needed handles for stdio */
585585
si.dwFlags = STARTF_USESTDHANDLES;

0 commit comments

Comments
 (0)