]> sourceware.org Git - newlib-cygwin.git/commitdiff
Cygwin: pty: Use pinfo() rather than kill() with signal 0.
authorTakashi Yano <takashi.yano@nifty.ne.jp>
Thu, 6 Feb 2020 10:48:17 +0000 (19:48 +0900)
committerCorinna Vinschen <corinna@vinschen.de>
Thu, 6 Feb 2020 18:58:31 +0000 (19:58 +0100)
- PTY code has a problem that tcsh is terminated if the following
  command is executed.
    true; chcp &
  This seems to be caused by invalid pointer access which occurs
  when the process exits during the kill() code is execuetd. This
  patch avoids the issue by not using kill().

winsup/cygwin/fhandler.h
winsup/cygwin/fhandler_tty.cc

index 9270c837ce95a443f700e9d321c441120451058a..82527eca370a893331acfe483b1614509b2d7b5b 100644 (file)
@@ -2211,7 +2211,7 @@ class fhandler_pty_slave: public fhandler_pty_common
   {
     if (!mask && get_ttyp ()->pcon_pid &&
        get_ttyp ()->pcon_pid != myself->pid &&
-       kill (get_ttyp ()->pcon_pid, 0) == 0)
+       !!pinfo (get_ttyp ()->pcon_pid))
       return;
     get_ttyp ()->mask_switch_to_pcon_in = mask;
   }
index 1dd57b369aee49d163ed4a9a904a2c6cd231209a..181bed5a960f88aaa0d0b6faf5e6157a489ba5a0 100644 (file)
@@ -1103,7 +1103,7 @@ fhandler_pty_slave::set_switch_to_pcon (int fd_set)
 skip_console_setting:
       restore_reattach_pcon ();
       if (get_ttyp ()->pcon_pid == 0 ||
-         kill (get_ttyp ()->pcon_pid, 0) != 0)
+         !pinfo (get_ttyp ()->pcon_pid))
        get_ttyp ()->pcon_pid = myself->pid;
       get_ttyp ()->switch_to_pcon_in = true;
     }
@@ -1111,7 +1111,7 @@ skip_console_setting:
     {
       wait_pcon_fwd ();
       if (get_ttyp ()->pcon_pid == 0 ||
-         kill (get_ttyp ()->pcon_pid, 0) != 0)
+         !pinfo (get_ttyp ()->pcon_pid))
        get_ttyp ()->pcon_pid = myself->pid;
       get_ttyp ()->switch_to_pcon_out = true;
     }
@@ -1124,7 +1124,7 @@ fhandler_pty_slave::reset_switch_to_pcon (void)
     this->set_switch_to_pcon (fd);
   if (get_ttyp ()->pcon_pid &&
       get_ttyp ()->pcon_pid != myself->pid &&
-      kill (get_ttyp ()->pcon_pid, 0) == 0)
+      !!pinfo (get_ttyp ()->pcon_pid))
     /* There is a process which is grabbing pseudo console. */
     return;
   if (isHybrid)
@@ -2728,7 +2728,7 @@ fhandler_pty_slave::fixup_after_attach (bool native_maybe, int fd_set)
                ENABLE_PROCESSED_INPUT | ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT;
              SetConsoleMode (get_handle (), mode);
              if (get_ttyp ()->pcon_pid == 0 ||
-                 kill (get_ttyp ()->pcon_pid, 0) != 0)
+                 !pinfo (get_ttyp ()->pcon_pid))
                get_ttyp ()->pcon_pid = myself->pid;
              get_ttyp ()->switch_to_pcon_in = true;
            }
@@ -2739,7 +2739,7 @@ fhandler_pty_slave::fixup_after_attach (bool native_maybe, int fd_set)
              if (!get_ttyp ()->switch_to_pcon_out)
                wait_pcon_fwd ();
              if (get_ttyp ()->pcon_pid == 0 ||
-                 kill (get_ttyp ()->pcon_pid, 0) != 0)
+                 !pinfo (get_ttyp ()->pcon_pid))
                get_ttyp ()->pcon_pid = myself->pid;
              get_ttyp ()->switch_to_pcon_out = true;
 
This page took 0.03805 seconds and 5 git commands to generate.