fix tcgetsid return type

Eric Blake eblake@redhat.com
Mon Feb 27 23:25:00 GMT 2012


Detected by gnulib's unit tests.  POSIX requires tcgetsid to return
pid_t, not int.

2012-02-27  Eric Blake  <eblake@redhat.com>

	* include/sys/termios.h (tcgetsid): Fix return type.
	* termios.cc (tcgetsid): Likewise.
	* fhandler_termios.cc (fhandler_termios::tcgetsid): Likewise.
	* fhandler.h (fhandler_base): Likewise.
	* fhandler.cc (fhandler_base::tcgetsid): Likewise.

diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc
index ef25a07..c3bca4f 100644
--- a/winsup/cygwin/fhandler.cc
+++ b/winsup/cygwin/fhandler.cc
@@ -1464,7 +1464,7 @@ fhandler_base::tcgetpgrp ()
   return -1;
 }

-int
+pid_t
 fhandler_base::tcgetsid ()
 {
   set_errno (ENOTTY);
diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h
index 605f59b..3b186bd 100644
--- a/winsup/cygwin/fhandler.h
+++ b/winsup/cygwin/fhandler.h
@@ -383,7 +383,7 @@ public:
   virtual int tcgetattr (struct termios *t);
   virtual int tcsetpgrp (const pid_t pid);
   virtual int tcgetpgrp ();
-  virtual int tcgetsid ();
+  virtual pid_t tcgetsid ();
   virtual bool is_tty () const { return false; }
   virtual bool ispipe () const { return false; }
   virtual pid_t get_popen_pid () const {return 0;}
@@ -1155,7 +1155,7 @@ class fhandler_termios: public fhandler_base
   virtual void __release_output_mutex (const char *fn, int ln) {}
   void echo_erase (int force = 0);
   virtual _off64_t lseek (_off64_t, int);
-  int tcgetsid ();
+  pid_t tcgetsid ();

   fhandler_termios (void *) {}

diff --git a/winsup/cygwin/fhandler_termios.cc
b/winsup/cygwin/fhandler_termios.cc
index c218fde..36017dc 100644
--- a/winsup/cygwin/fhandler_termios.cc
+++ b/winsup/cygwin/fhandler_termios.cc
@@ -1,7 +1,7 @@
 /* fhandler_termios.cc

    Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008, 2009,
-   2010, 2011 Red Hat, Inc.
+   2010, 2011, 2012 Red Hat, Inc.

 This file is part of Cygwin.

@@ -401,7 +401,7 @@ fhandler_termios::sigflush ()
     tcflush (TCIFLUSH);
 }

-int
+pid_t
 fhandler_termios::tcgetsid ()
 {
   if (myself->ctty != -1 && myself->ctty == tc ()->ntty)
diff --git a/winsup/cygwin/include/sys/termios.h
b/winsup/cygwin/include/sys/termios.h
index a0d1b24..a87f9de 100644
--- a/winsup/cygwin/include/sys/termios.h
+++ b/winsup/cygwin/include/sys/termios.h
@@ -1,7 +1,7 @@
 /* sys/termios.h

    Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006,
-   2007, 2008, 2009, 2010, 2011 Red Hat, Inc.
+   2007, 2008, 2009, 2010, 2011, 2012 Red Hat, Inc.

 This file is part of Cygwin.

@@ -14,6 +14,8 @@ details. */
 #ifndef	_SYS_TERMIOS_H
 #define _SYS_TERMIOS_H

+#include <sys/types.h>
+
 #define	TIOCMGET	0x5415
 #define	TIOCMBIS	0x5416
 #define	TIOCMBIC	0x5417
@@ -328,7 +330,7 @@ int tcsendbreak (int, int);
 int tcdrain (int);
 int tcflush (int, int);
 int tcflow (int, int);
-int tcgetsid (int);
+pid_t tcgetsid (int);
 void cfmakeraw (struct termios *);
 speed_t cfgetispeed(const struct termios *);
 speed_t cfgetospeed(const struct termios *);
diff --git a/winsup/cygwin/termios.cc b/winsup/cygwin/termios.cc
index 3096513..0fb0de2 100644
--- a/winsup/cygwin/termios.cc
+++ b/winsup/cygwin/termios.cc
@@ -1,7 +1,7 @@
 /* termios.cc: termios for WIN32.

    Copyright 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
-   2007, 2008, 2009, 2010, 2011 Red Hat, Inc.
+   2007, 2008, 2009, 2010, 2011, 2012 Red Hat, Inc.

    Written by Doug Evans and Steve Chamberlain of Cygnus Support
    dje@cygnus.com, sac@cygnus.com
@@ -207,7 +207,7 @@ tcgetpgrp (int fd)
   return res;
 }

-extern "C" int
+extern "C" pid_t
 tcgetsid (int fd)
 {
   int res;

-- 
Eric Blake   eblake@redhat.com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 620 bytes
Desc: OpenPGP digital signature
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20120227/8705a40e/attachment.sig>


More information about the Cygwin-patches mailing list