Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions winsup/cygwin/fhandler/termios.cc
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,10 @@ fhandler_termios::spawn_worker::setup (bool iscygwin, HANDLE h_stdin,
fhandler_pty_slave *ptys_primary = NULL;
fhandler_console *cons_native = NULL;

/* This may resolve an app execution alias, which allocates cygheap memory.
Do it before child_info_spawn::worker() acquires the cygheap lock. */
console_app = !iscygwin && is_console_app (pc);

for (int i = 0; i < 3; i ++)
{
const int chk_order[] = {1, 0, 2};
Expand Down Expand Up @@ -811,7 +815,7 @@ fhandler_termios::spawn_worker::setup (bool iscygwin, HANDLE h_stdin,
ptys->setup_locale ();
}
}
if (!iscygwin && ptys_primary && is_console_app (pc))
if (ptys_primary && console_app)
{
if (h_stdin == ptys_primary->get_handle_nat ())
stdin_is_ptys = true;
Expand Down Expand Up @@ -852,9 +856,9 @@ fhandler_termios::spawn_worker::is_attaching (DWORD pid)

void
fhandler_termios::spawn_worker::wait_for_resume_if_necessary
(path_conv &pc, PROCESS_INFORMATION &pi)
(PROCESS_INFORMATION &pi)
{
if (is_attaching (myself->dwProcessId) && is_console_app (pc))
if (is_attaching (myself->dwProcessId) && console_app)
{
DWORD t0 = GetTickCount ();
while (GetTickCount () - t0 < 40 && !is_attaching (pi.dwProcessId)
Expand Down
5 changes: 3 additions & 2 deletions winsup/cygwin/local_includes/fhandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -2033,17 +2033,18 @@ class fhandler_termios: public fhandler_base
bool ptys_need_cleanup;
bool cons_need_cleanup;
bool stdin_is_ptys;
bool console_app;
tty *ptys_ttyp;
public:
spawn_worker () :
ptys_need_cleanup (false), cons_need_cleanup (false),
stdin_is_ptys (false), ptys_ttyp (NULL) {}
stdin_is_ptys (false), console_app (false), ptys_ttyp (NULL) {}
void setup (bool iscygwin, HANDLE h_stdin, path_conv &pc,
bool nopcon, bool reset_sendsig, const WCHAR *envblock);
bool need_cleanup () { return ptys_need_cleanup || cons_need_cleanup; }
void cleanup ();
bool is_attaching (DWORD pid);
void wait_for_resume_if_necessary (path_conv &, PROCESS_INFORMATION &);
void wait_for_resume_if_necessary (PROCESS_INFORMATION &);
};
};

Expand Down
2 changes: 1 addition & 1 deletion winsup/cygwin/spawn.cc
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ child_info_spawn::worker (const char *prog_arg, const char *const *argv,
DuplicateHandle (GetCurrentProcess (), wr_proc_pipe, pi.hProcess,
NULL, 0, false, DUPLICATE_SAME_ACCESS);
ResumeThread (pi.hThread);
term_spawn_worker.wait_for_resume_if_necessary (real_path, pi);
term_spawn_worker.wait_for_resume_if_necessary (pi);
}

if (mode == _P_OVERLAY)
Expand Down
Loading