This is the mail archive of the cygwin-cvs@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[newlib-cygwin] Generate SIGHUP for terminal process group on tty master close


https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=511eb2f264c582ac753650b4848edae5b6d8c968

commit 511eb2f264c582ac753650b4848edae5b6d8c968
Author: Takashi Yano <takashi.yano@nifty.ne.jp>
Date:   Mon Jun 8 14:07:42 2015 +0200

    Generate SIGHUP for terminal process group on tty master close
    
    	* fhandler_tty.cc (fhandler_pty_slave::write): Move causing of SIGHUP
    	into fhandler_pty_master::close().
    	(fhandler_pty_slave::read): Ditto.
    	(fhandler_pty_master::close): Ditto.
    
    Signed-off-by: Corinna Vinschen <corinna@vinschen.de>

Diff:
---
 winsup/cygwin/ChangeLog       |  7 +++++++
 winsup/cygwin/fhandler_tty.cc | 24 ++++++++++++++++++------
 2 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 4a663af..894094c 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,10 @@
+2015-06-08  Takashi Yano  <takashi.yano@nifty.ne.jp>
+
+	* fhandler_tty.cc (fhandler_pty_slave::write): Move causing of SIGHUP
+	into fhandler_pty_master::close().
+	(fhandler_pty_slave::read): Ditto.
+	(fhandler_pty_master::close): Ditto.
+
 2015-06-08  Corinna Vinschen  <corinna@vinschen.de>
 
 	* include/cygwin/version.h (CYGWIN_VERSION_DLL_MINOR): Bump to 4.
diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc
index 1b5c18b..f22998f 100644
--- a/winsup/cygwin/fhandler_tty.cc
+++ b/winsup/cygwin/fhandler_tty.cc
@@ -622,7 +622,6 @@ fhandler_pty_slave::write (const void *ptr, size_t len)
 	default:
 	  __seterrno_from_win_error (err);
 	}
-      raise (SIGHUP);		/* FIXME: Should this be SIGTTOU? */
       towrite = -1;
     }
   return towrite;
@@ -749,7 +748,12 @@ fhandler_pty_slave::read (void *ptr, size_t& len)
 	  goto out;
 	}
       if (!bytes_available (bytes_in_pipe))
-	raise (SIGHUP);
+	{
+	  ReleaseMutex (input_mutex);
+	  set_errno (EIO);
+	  totalread = -1;
+	  goto out;
+	}
 
       /* On first peek determine no. of bytes to flush. */
       if (!ptr && len == UINT_MAX)
@@ -779,9 +783,10 @@ fhandler_pty_slave::read (void *ptr, size_t& len)
 	  if (!ReadFile (get_handle (), buf, readlen, &n, NULL))
 	    {
 	      termios_printf ("read failed, %E");
-	      raise (SIGHUP);
-	      bytes_in_pipe = 0;
-	      ptr = NULL;
+	      ReleaseMutex (input_mutex);
+	      set_errno (EIO);
+	      totalread = -1;
+	      goto out;
 	    }
 	  else
 	    {
@@ -790,7 +795,12 @@ fhandler_pty_slave::read (void *ptr, size_t& len)
 		 change after successful read. So we have to peek into the pipe
 		 again to see if input is still available */
 	      if (!bytes_available (bytes_in_pipe))
-		raise (SIGHUP);
+		{
+		  ReleaseMutex (input_mutex);
+		  set_errno (EIO);
+		  totalread = -1;
+		  goto out;
+		}
 	      if (n)
 		{
 		  len -= n;
@@ -1269,6 +1279,8 @@ fhandler_pty_master::close ()
   else if (obi.HandleCount == 1)
     {
       termios_printf("Closing last master of pty%d", get_minor ());
+      if (get_ttyp ()->getsid () > 0)
+	kill (get_ttyp ()->getsid (), SIGHUP);
       SetEvent (input_available_event);
     }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]