OSDN Git Service

* fhandler.h (fhandler_pty_master::tcgetpgrp): Declare.
authorcorinna <corinna>
Wed, 7 Oct 2009 07:52:29 +0000 (07:52 +0000)
committercorinna <corinna>
Wed, 7 Oct 2009 07:52:29 +0000 (07:52 +0000)
* fhandler_termios.cc (fhandler_termios::tcgetpgrp): Only return
valid pgid if tty is controlling tty.  Set errno to ENOTTY and
return -1 otherwise.
(fhandler_pty_master::tcgetpgrp): New function.  Return 0 for
master side of pty if it's not the controlling tty of the process.

winsup/cygwin/ChangeLog
winsup/cygwin/fhandler.h
winsup/cygwin/fhandler_termios.cc

index ffa5471..b1c7f3a 100644 (file)
@@ -1,3 +1,12 @@
+2009-10-07  Corinna Vinschen  <corinna@vinschen.de>
+
+       * fhandler.h (fhandler_pty_master::tcgetpgrp): Declare.
+       * fhandler_termios.cc (fhandler_termios::tcgetpgrp): Only return
+       valid pgid if tty is controlling tty.  Set errno to ENOTTY and
+       return -1 otherwise.
+       (fhandler_pty_master::tcgetpgrp): New function.  Return 0 for
+       master side of pty if it's not the controlling tty of the process.
+
 2009-10-05  Charles Wilson  <cygwin@cwilson.fastmail.fm>
 
        Add cygwin wrapper for ExitProcess and TerminateProcess.
index dac0ce2..cb12d2b 100644 (file)
@@ -1109,6 +1109,7 @@ public:
   int dup (fhandler_base *);
   void fixup_after_fork (HANDLE parent);
   void fixup_after_exec ();
+  int tcgetpgrp ();
 };
 
 class fhandler_tty_master: public fhandler_pty_master
index 8bdfdcd..b5d9f2e 100644 (file)
@@ -99,7 +99,16 @@ fhandler_termios::tcsetpgrp (const pid_t pgid)
 int
 fhandler_termios::tcgetpgrp ()
 {
-  return tc->pgid;
+  if (myself->ctty != -1 && myself->ctty == tc->ntty)
+    return tc->pgid;
+  set_errno (ENOTTY);
+  return -1;
+}
+
+int
+fhandler_pty_master::tcgetpgrp ()
+{
+  return myself->ctty != -1 && myself->ctty == tc->ntty ? tc->pgid : 0;
 }
 
 void