From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id 76EC0384F483; Sun, 4 Dec 2022 13:27:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 76EC0384F483 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1670160462; bh=nVOa9uUMb4Db5qQotVsV3z9p7koUnNGp6RY4VfffCBQ=; h=From:To:Subject:Date:From; b=uGcaNw8ifMgwbtXc3/9EKv5gdSl3HvG4/wsQn3bl3jZ64TRDQqLvRm0kz8jwXesEx QXmMGcJBkb2yGag24sDFBi08G56PH0/ZvdXP+vw5EEzevdgd52zm8Omdu3N2Vw0D5I J9oh00yUPdLZ+HiwLEIvzfV4vWAoD++eoJaaEQ3o= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Corinna Vinschen To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: drop wincap::has_broken_attach_console X-Act-Checkin: newlib-cygwin X-Git-Author: Corinna Vinschen X-Git-Refname: refs/heads/master X-Git-Oldrev: 4e40b214649139623c96923f678f1ee85c90286d X-Git-Newrev: 08cd9cfc5c7ee1d0d1c84d1c708a2e6446c7c337 Message-Id: <20221204132742.76EC0384F483@sourceware.org> Date: Sun, 4 Dec 2022 13:27:42 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D08cd9cfc5c7= ee1d0d1c84d1c708a2e6446c7c337 commit 08cd9cfc5c7ee1d0d1c84d1c708a2e6446c7c337 Author: Corinna Vinschen AuthorDate: Tue Nov 15 17:39:10 2022 +0100 Commit: Corinna Vinschen CommitDate: Sun Dec 4 14:01:41 2022 +0100 Cygwin: drop wincap::has_broken_attach_console =20 Only required for Windows 7. =20 This in turn allows to drop the helper_pid and related methods from fhandler_pty_common. =20 Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/fhandler/pty.cc | 66 +++--------------------------= ---- winsup/cygwin/fhandler/termios.cc | 3 +- winsup/cygwin/local_includes/fhandler.h | 6 +-- winsup/cygwin/local_includes/wincap.h | 2 - winsup/cygwin/wincap.cc | 12 ------ 5 files changed, 7 insertions(+), 82 deletions(-) diff --git a/winsup/cygwin/fhandler/pty.cc b/winsup/cygwin/fhandler/pty.cc index 7959d4b0ac40..e7106daba48b 100644 --- a/winsup/cygwin/fhandler/pty.cc +++ b/winsup/cygwin/fhandler/pty.cc @@ -547,8 +547,7 @@ fhandler_pty_master::accept_input () { /* Slave attaches to a different console than master. Therefore reattach here. */ - DWORD resume_pid =3D - attach_console_temporarily (target_pid, helper_pid); + DWORD resume_pid =3D attach_console_temporarily (target_pid); cp_to =3D GetConsoleCP (); resume_from_temporarily_attach (resume_pid); } @@ -2111,7 +2110,6 @@ fhandler_pty_master::close () WaitForSingleObject (helper_h_process, INFINITE); CloseHandle (helper_h_process); CloseHandle (helper_goodbye); - helper_pid =3D 0; helper_h_process =3D 0; helper_goodbye =3D NULL; } @@ -2838,7 +2836,7 @@ fhandler_pty_master::pty_master_fwd_thread (const mas= ter_fwd_thread_param_t *p) /* Slave attaches to a different console than master. Therefore reattach here. */ DWORD resume_pid =3D - attach_console_temporarily (target_pid, p->helper_pid); + attach_console_temporarily (target_pid); cp_from =3D GetConsoleOutputCP (); resume_from_temporarily_attach (resume_pid); } @@ -3022,56 +3020,6 @@ fhandler_pty_master::setup () } WaitForSingleObject (thread_param_copied_event, INFINITE); =20 - if (wincap.has_broken_attach_console () - && _major (myself->ctty) =3D=3D DEV_CONS_MAJOR - && !(!pinfo (myself->ppid) && getenv ("ConEmuPID"))) - { - HANDLE hello =3D CreateEvent (&sec_none, true, false, NULL); - HANDLE goodbye =3D CreateEvent (&sec_none, true, false, NULL); - WCHAR cmd[MAX_PATH]; - path_conv helper ("/bin/cygwin-console-helper.exe"); - size_t len =3D helper.get_wide_win32_path_len (); - helper.get_wide_win32_path (cmd); - __small_swprintf (cmd + len, L" %p %p", hello, goodbye); - - STARTUPINFOEXW si; - PROCESS_INFORMATION pi; - ZeroMemory (&si, sizeof (si)); - si.StartupInfo.cb =3D sizeof (STARTUPINFOEXW); - - SIZE_T bytesRequired; - InitializeProcThreadAttributeList (NULL, 1, 0, &bytesRequired); - si.lpAttributeList =3D (PPROC_THREAD_ATTRIBUTE_LIST) - HeapAlloc (GetProcessHeap (), 0, bytesRequired); - InitializeProcThreadAttributeList (si.lpAttributeList, - 1, 0, &bytesRequired); - HANDLE handles_to_inherit[] =3D {hello, goodbye}; - UpdateProcThreadAttribute (si.lpAttributeList, - 0, - PROC_THREAD_ATTRIBUTE_HANDLE_LIST, - handles_to_inherit, - sizeof (handles_to_inherit), - NULL, NULL); - if (CreateProcessW (NULL, cmd, &sec_none, &sec_none, - TRUE, EXTENDED_STARTUPINFO_PRESENT, - NULL, NULL, &si.StartupInfo, &pi)) - { - WaitForSingleObject (hello, INFINITE); - CloseHandle (hello); - CloseHandle (pi.hThread); - helper_goodbye =3D goodbye; - helper_pid =3D pi.dwProcessId; - helper_h_process =3D pi.hProcess; - } - else - { - CloseHandle (hello); - CloseHandle (goodbye); - } - DeleteProcThreadAttributeList (si.lpAttributeList); - HeapFree (GetProcessHeap (), 0, si.lpAttributeList); - } - master_fwd_thread =3D new cygthread (::pty_master_fwd_thread, this, "pty= mf"); if (!master_fwd_thread) { @@ -3877,7 +3825,6 @@ fhandler_pty_master::get_master_fwd_thread_param (mas= ter_fwd_thread_param_t *p) p->from_slave_nat =3D from_slave_nat; p->output_mutex =3D output_mutex; p->ttyp =3D get_ttyp (); - p->helper_pid =3D helper_pid; SetEvent (thread_param_copied_event); } =20 @@ -4189,7 +4136,7 @@ fhandler_pty_slave::setpgid_aux (pid_t pid) 0, TRUE, DUPLICATE_SAME_ACCESS); CloseHandle (pcon_owner); DWORD target_pid =3D get_ttyp ()->nat_pipe_owner_pid; - resume_pid =3D attach_console_temporarily (target_pid, 0); + resume_pid =3D attach_console_temporarily (target_pid); attach_restore =3D true; } else @@ -4235,15 +4182,12 @@ fhandler_pty_slave::release_ownership_of_nat_pipe (= tty *ttyp, } =20 DWORD -fhandler_pty_common::attach_console_temporarily (DWORD target_pid, - DWORD helper_pid) +fhandler_pty_common::attach_console_temporarily (DWORD target_pid) { DWORD resume_pid =3D 0; acquire_attach_mutex (mutex_timeout); pinfo pinfo_resume (myself->ppid); - if (helper_pid) - resume_pid =3D helper_pid; - else if (pinfo_resume) + if (pinfo_resume) resume_pid =3D pinfo_resume->dwProcessId; if (!resume_pid) resume_pid =3D get_console_process_id (myself->dwProcessId, false); diff --git a/winsup/cygwin/fhandler/termios.cc b/winsup/cygwin/fhandler/ter= mios.cc index 517e74e7749e..fe4dfd13ecdd 100644 --- a/winsup/cygwin/fhandler/termios.cc +++ b/winsup/cygwin/fhandler/termios.cc @@ -359,8 +359,7 @@ fhandler_termios::process_sigs (char c, tty* ttyp, fhan= dler_termios *fh) DWORD resume_pid =3D 0; if (fh && !fh->is_console ()) resume_pid =3D - fhandler_pty_common::attach_console_temporarily - (p->dwProcessId, fh->get_helper_pid ()); + fhandler_pty_common::attach_console_temporarily (p->dwProcessId); if (fh && p =3D=3D myself && being_debugged ()) { /* Avoid deadlock in gdb on console. */ fh->tcflush(TCIFLUSH); diff --git a/winsup/cygwin/local_includes/fhandler.h b/winsup/cygwin/local_= includes/fhandler.h index 6671d8a05c60..8c320421b6b6 100644 --- a/winsup/cygwin/local_includes/fhandler.h +++ b/winsup/cygwin/local_includes/fhandler.h @@ -1987,7 +1987,6 @@ class fhandler_termios: public fhandler_base virtual void setpgid_aux (pid_t pid) {} virtual bool need_console_handler () { return false; } virtual bool need_send_ctrl_c_event () { return true; } - virtual DWORD get_helper_pid () { return 0; } =20 struct ptys_handle_set_t { @@ -2378,7 +2377,7 @@ class fhandler_pty_common: public fhandler_termios bool cygwin =3D false, bool stub_only =3D false); bool to_be_read_from_nat_pipe (void); - static DWORD attach_console_temporarily (DWORD target_pid, DWORD helper_= pid); + static DWORD attach_console_temporarily (DWORD target_pid); static void resume_from_temporarily_attach (DWORD resume_pid); =20 protected: @@ -2501,7 +2500,6 @@ public: HANDLE from_slave_nat; HANDLE output_mutex; tty *ttyp; - DWORD helper_pid; }; private: int pktmode; // non-zero if pty in a packet mode. @@ -2515,7 +2513,6 @@ private: HANDLE thread_param_copied_event; HANDLE helper_goodbye; HANDLE helper_h_process; - DWORD helper_pid; =20 public: HANDLE get_echo_handle () const { return echo_r; } @@ -2570,7 +2567,6 @@ public: void get_master_fwd_thread_param (master_fwd_thread_param_t *p); void set_mask_flusho (bool m) { get_ttyp ()->mask_flusho =3D m; } bool need_send_ctrl_c_event (); - DWORD get_helper_pid () { return helper_pid; } }; =20 class fhandler_dev_null: public fhandler_base diff --git a/winsup/cygwin/local_includes/wincap.h b/winsup/cygwin/local_in= cludes/wincap.h index 17d2d74293d1..c26324fd6dac 100644 --- a/winsup/cygwin/local_includes/wincap.h +++ b/winsup/cygwin/local_includes/wincap.h @@ -33,7 +33,6 @@ struct wincaps unsigned has_linux_tcp_keepalive_sockopts : 1; unsigned has_tcp_maxrtms : 1; unsigned has_con_broken_tabs : 1; - unsigned has_broken_attach_console : 1; unsigned cons_need_small_input_record_buf : 1; }; }; @@ -87,7 +86,6 @@ public: bool IMPLEMENT (has_linux_tcp_keepalive_sockopts) bool IMPLEMENT (has_tcp_maxrtms) bool IMPLEMENT (has_con_broken_tabs) - bool IMPLEMENT (has_broken_attach_console) bool IMPLEMENT (cons_need_small_input_record_buf) =20 void disable_case_sensitive_dirs () diff --git a/winsup/cygwin/wincap.cc b/winsup/cygwin/wincap.cc index c52d4154010c..fe5986c76e21 100644 --- a/winsup/cygwin/wincap.cc +++ b/winsup/cygwin/wincap.cc @@ -40,7 +40,6 @@ wincaps wincap_7 __attribute__((section (".cygwin_dll_com= mon"), shared)) =3D { has_linux_tcp_keepalive_sockopts:false, has_tcp_maxrtms:false, has_con_broken_tabs:false, - has_broken_attach_console:true, cons_need_small_input_record_buf:true, }, }; @@ -66,7 +65,6 @@ wincaps wincap_8 __attribute__((section (".cygwin_dll_com= mon"), shared)) =3D { has_linux_tcp_keepalive_sockopts:false, has_tcp_maxrtms:false, has_con_broken_tabs:false, - has_broken_attach_console:false, cons_need_small_input_record_buf:false, }, }; @@ -92,7 +90,6 @@ wincaps wincap_8_1 __attribute__((section (".cygwin_dll_c= ommon"), shared)) =3D { has_linux_tcp_keepalive_sockopts:false, has_tcp_maxrtms:false, has_con_broken_tabs:false, - has_broken_attach_console:false, cons_need_small_input_record_buf:false, }, }; @@ -118,7 +115,6 @@ wincaps wincap_10_1507 __attribute__((section (".cygwi= n_dll_common"), shared)) has_linux_tcp_keepalive_sockopts:false, has_tcp_maxrtms:false, has_con_broken_tabs:false, - has_broken_attach_console:false, cons_need_small_input_record_buf:false, }, }; @@ -144,7 +140,6 @@ wincaps wincap_10_1607 __attribute__((section (".cygwi= n_dll_common"), shared)) has_linux_tcp_keepalive_sockopts:false, has_tcp_maxrtms:true, has_con_broken_tabs:false, - has_broken_attach_console:false, cons_need_small_input_record_buf:false, }, }; @@ -170,7 +165,6 @@ wincaps wincap_10_1703 __attribute__((section (".cygwin= _dll_common"), shared)) =3D has_linux_tcp_keepalive_sockopts:false, has_tcp_maxrtms:true, has_con_broken_tabs:true, - has_broken_attach_console:false, cons_need_small_input_record_buf:false, }, }; @@ -196,7 +190,6 @@ wincaps wincap_10_1709 __attribute__((section (".cygwin= _dll_common"), shared)) =3D has_linux_tcp_keepalive_sockopts:true, has_tcp_maxrtms:true, has_con_broken_tabs:true, - has_broken_attach_console:false, cons_need_small_input_record_buf:false, }, }; @@ -222,7 +215,6 @@ wincaps wincap_10_1803 __attribute__((section (".cygwin= _dll_common"), shared)) =3D has_linux_tcp_keepalive_sockopts:true, has_tcp_maxrtms:true, has_con_broken_tabs:true, - has_broken_attach_console:false, cons_need_small_input_record_buf:false, }, }; @@ -248,7 +240,6 @@ wincaps wincap_10_1809 __attribute__((section (".cygwin= _dll_common"), shared)) =3D has_linux_tcp_keepalive_sockopts:true, has_tcp_maxrtms:true, has_con_broken_tabs:true, - has_broken_attach_console:false, cons_need_small_input_record_buf:false, }, }; @@ -274,7 +265,6 @@ wincaps wincap_10_1903 __attribute__((section (".cygwin= _dll_common"), shared)) =3D has_linux_tcp_keepalive_sockopts:true, has_tcp_maxrtms:true, has_con_broken_tabs:true, - has_broken_attach_console:false, cons_need_small_input_record_buf:false, }, }; @@ -300,7 +290,6 @@ wincaps wincap_10_2004 __attribute__((section (".cygwin= _dll_common"), shared)) =3D has_linux_tcp_keepalive_sockopts:true, has_tcp_maxrtms:true, has_con_broken_tabs:true, - has_broken_attach_console:false, cons_need_small_input_record_buf:false, }, }; @@ -326,7 +315,6 @@ wincaps wincap_11 __attribute__((section (".cygwin_dll_= common"), shared)) =3D { has_linux_tcp_keepalive_sockopts:true, has_tcp_maxrtms:true, has_con_broken_tabs:false, - has_broken_attach_console:false, cons_need_small_input_record_buf:false, }, };