From 71d59a926f9d632b15c531325bad15edb32b8f81 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Sat, 3 Jun 2006 20:32:07 +0000 Subject: * dcrt0.cc (dll_crt0_0): Call tty_list::init_session here. (dll_crt0_1): Reflect renaming from tty_init to tty::init_session. (do_exit): Reflect moving of tty_terminate into tty_list. * exceptions.cc (events_init): Move tty_mutex stuff elsewhere. * fhandler_console.cc (set_console_title): Use lock_ttys class. * fhandler_termios.cc (fhandler_termios::bg_check): Make debug output more accurate. * fhandler_tty.cc (fhandler_tty_slave::open): Reflect move of attach_tty into tty_list class. Don't attempt to grab master end of pty if master doesn't exist. (fhandler_pty_master::open): Reflect move of allocate_tty into tty_list class. Use lock_ttys::release to release mutex. Improve debugging output. (fhandler_pty_master::setup): Remove if 0'ed block. Fix argument to SetNamedPipeHandleState. * pinfo.cc (_pinfo::set_ctty): Lock ttys before setting sid/pgid. Improve debugging. Add temporary debugging. * tty.cc (tty_list::init_session): New function. (tty::init_session): Rename from tty_init. Reflect move of attach_tty to tty_list class. (tty::create_master): Rename from create_tty_master. (tty_list::attach): Rename from attach_tty. Reflect renaming of connect_tty to connect. Ditto for allocate_tty. (tty_terminate): Delete. (tty_list::terminate): Subsume tty_terminate. Use lock_ttys rather than manipulating mutex directly. (tty_list::allocate): Rename from allocate_tty. Use lock_ttys rather than manipulating mutex directly. Don't set sid here since linux apparently doesn't do this. Reflect move of create_tty_master into tty. (lock_ttys::lock_ttys): Define new constructor. (lock_ttys::release): New function. * tty.h (tty::exists): Return false immediately if !master_pid. (tty::set_master_closed): Define new function. (tty::create_master): Ditto. (tty::init_session): Ditto. (tty_list::mutex): New field. (tty_list::allocate): Define new function. (tty_list::connect): Ditto. (tty_list::attach): Ditto. (tty_list::init_session): Ditto. (lock_ttys): New class. (tty_init): Delete declaration. (tty_terminate): Ditto. (attach_tty): Ditto. (create_tty_master): Ditto. --- winsup/cygwin/exceptions.cc | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) (limited to 'winsup/cygwin/exceptions.cc') diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index a5e71d86a..4d078dd10 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -369,7 +369,7 @@ try_to_debug (bool waitloop) /* if any of these mutexes is owned, we will fail to start any cygwin app until trapped app exits */ - ReleaseMutex (tty_mutex); + lock_ttys::release (); /* prevent recursive exception handling */ char* rawenv = GetEnvironmentStrings () ; @@ -1297,22 +1297,9 @@ _cygtls::signal_exit (int rc) do_exit (rc); } -HANDLE NO_COPY tty_mutex = NULL; - void events_init () { - char *name; - char mutex_name[CYG_MAX_PATH]; - /* tty_mutex is on while searching for a tty slot. It's necessary - while finding console window handle */ - - if (!(tty_mutex = CreateMutex (&sec_all_nih, FALSE, - name = shared_name (mutex_name, - "tty_mutex", 0)))) - api_fatal ("can't create title mutex '%s', %E", name); - - ProtectHandle (tty_mutex); mask_sync.init ("mask_sync"); windows_system_directory[0] = '\0'; GetSystemDirectory (windows_system_directory, sizeof (windows_system_directory) - 2); @@ -1393,7 +1380,7 @@ _cygtls::copy_context (CONTEXT *c) void _cygtls::signal_debugger (int sig) { - if (being_debugged ()) + if (isinitialized () && being_debugged ()) { char sigmsg[2 * sizeof (_CYGWIN_SIGNAL_STRING " ffffffff ffffffff")]; __small_sprintf (sigmsg, _CYGWIN_SIGNAL_STRING " %d %p %p", sig, thread_id, &thread_context); -- cgit v1.2.3