Cygwin: console: Fix exit code for non-cygwin process.

If non-cygwin process is executed in console, the exit code is not
set correctly. This is because the stub process for non-cygwin app
crashes in fhandler_console::set_disable_master_thread() due to NULL
pointer dereference. This bug was introduced by the commit:
3721a756b0 ("Cygwin: console: Make the console accessible from
other terminals."), that the pointer cons is accessed before fixing
when it is NULL. This patch fixes the issue.

Fixes: 3721a756b0 ("Cygwin: console: Make the console accessible from other terminals.")
Reported-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
This commit is contained in:
Takashi Yano 2024-02-02 13:59:19 +09:00
parent 23737b04cc
commit aa73e11524
1 changed files with 3 additions and 3 deletions

View File

@ -4537,9 +4537,6 @@ fhandler_console::need_console_handler ()
void void
fhandler_console::set_disable_master_thread (bool x, fhandler_console *cons) fhandler_console::set_disable_master_thread (bool x, fhandler_console *cons)
{ {
const _minor_t unit = cons->get_minor ();
if (con.disable_master_thread == x)
return;
if (cons == NULL) if (cons == NULL)
{ {
if (cygheap->ctty && cygheap->ctty->get_major () == DEV_CONS_MAJOR) if (cygheap->ctty && cygheap->ctty->get_major () == DEV_CONS_MAJOR)
@ -4547,6 +4544,9 @@ fhandler_console::set_disable_master_thread (bool x, fhandler_console *cons)
else else
return; return;
} }
const _minor_t unit = cons->get_minor ();
if (con.disable_master_thread == x)
return;
cons->acquire_input_mutex (mutex_timeout); cons->acquire_input_mutex (mutex_timeout);
con.disable_master_thread = x; con.disable_master_thread = x;
cons->release_input_mutex (); cons->release_input_mutex ();