Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2011-11-08 00:05:49 +0400
committerChristopher Faylor <me@cgf.cx>2011-11-08 00:05:49 +0400
commit65a6152f18884f2867b4350723bdcff5732e3f29 (patch)
treea9469b6d6b77ad6bbf2c1e6d1c7f6943a1566214 /winsup/cygwin
parent78942629ac8b7683f64fb21b39a4c1eaee2b768b (diff)
* cygwin.din (ptsname_r): Export.
* fhandler.cc (fhandler_base::ptsname_r): Define. * fhandler.h (fhandler_base::ptsname): Delete. (fhandler_base::ptsname_r): Declare. (fhandler_pty_master::ptsname_r): Declare. * fhandler_tty.cc (fhandler_pty_master::ptsname): Delete. (fhandler_pty_master::ptsname_r): New reentrant function derived from previous ptsname. * syscalls.cc (ptsname_r): Implement new function with functionality similar to Linux. (ptsname): Use ptsname_r () to fill out buf. * include/cygwin/stdlib.h (ptsname_r): Declare. * include/cygwin/version.h: Bump CYGWIN_VERSION_API_MINOR to 255 to reflect export of ptsname_r. * pinfo.cc (pinfo::wait): Return bool rather than int. * pinfo.h (info::wait): Ditto. (pinfo::reattach): Define !defined(_SIGPROC_H) case for consistency. * sigproc.cc (child_info_spawn::reattach_children): Use correct dwProcessId rather than pid when duplicating handle.
Diffstat (limited to 'winsup/cygwin')
-rw-r--r--winsup/cygwin/ChangeLog23
-rw-r--r--winsup/cygwin/cygwin.din1
-rw-r--r--winsup/cygwin/fhandler.cc7
-rw-r--r--winsup/cygwin/fhandler.h4
-rw-r--r--winsup/cygwin/fhandler_tty.cc16
-rw-r--r--winsup/cygwin/include/cygwin/stdlib.h1
-rw-r--r--winsup/cygwin/include/cygwin/version.h3
-rw-r--r--winsup/cygwin/pinfo.cc10
-rw-r--r--winsup/cygwin/pinfo.h3
-rw-r--r--winsup/cygwin/sigproc.cc2
-rw-r--r--winsup/cygwin/syscalls.cc15
11 files changed, 69 insertions, 16 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 2bba38a56..4922a7c8b 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,26 @@
+2011-11-07 Christopher Faylor <me.cygwin2011@cgf.cx>
+
+ * cygwin.din (ptsname_r): Export.
+ * fhandler.cc (fhandler_base::ptsname_r): Define.
+ * fhandler.h (fhandler_base::ptsname): Delete.
+ (fhandler_base::ptsname_r): Declare.
+ (fhandler_pty_master::ptsname_r): Declare.
+ * fhandler_tty.cc (fhandler_pty_master::ptsname): Delete.
+ (fhandler_pty_master::ptsname_r): New reentrant function derived from
+ previous ptsname.
+ * syscalls.cc (ptsname_r): Implement new function with functionality
+ similar to Linux.
+ (ptsname): Use ptsname_r () to fill out buf.
+ * include/cygwin/stdlib.h (ptsname_r): Declare.
+ * include/cygwin/version.h: Bump CYGWIN_VERSION_API_MINOR to 255 to
+ reflect export of ptsname_r.
+
+ * pinfo.cc (pinfo::wait): Return bool rather than int.
+ * pinfo.h (info::wait): Ditto.
+ (pinfo::reattach): Define !defined(_SIGPROC_H) case for consistency.
+ * sigproc.cc (child_info_spawn::reattach_children): Use correct
+ dwProcessId rather than pid when duplicating handle.
+
2011-11-07 Corinna Vinschen <corinna@vinschen.de>
* fhandler.cc (CHUNK_SIZE): Drop NO_COPY.
diff --git a/winsup/cygwin/cygwin.din b/winsup/cygwin/cygwin.din
index 594edda9f..615088a56 100644
--- a/winsup/cygwin/cygwin.din
+++ b/winsup/cygwin/cygwin.din
@@ -1277,6 +1277,7 @@ pthread_spin_unlock SIGFE
pthread_testcancel SIGFE
pthread_yield = sched_yield SIGFE
ptsname SIGFE
+ptsname_r SIGFE
putc SIGFE
_putc = putc SIGFE
putc_unlocked SIGFE
diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc
index deede57fa..98c6bb954 100644
--- a/winsup/cygwin/fhandler.cc
+++ b/winsup/cygwin/fhandler.cc
@@ -1407,6 +1407,13 @@ fhandler_base::tcgetsid ()
return -1;
}
+int
+fhandler_base::ptsname_r (char *, size_t)
+{
+ set_errno (ENOTTY);
+ return ENOTTY;
+}
+
void
fhandler_base::operator delete (void *p)
{
diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h
index 900dd936a..189c0f3b5 100644
--- a/winsup/cygwin/fhandler.h
+++ b/winsup/cygwin/fhandler.h
@@ -381,7 +381,7 @@ public:
virtual pid_t get_popen_pid () const {return 0;}
virtual bool isdevice () const { return true; }
virtual bool isfifo () const { return false; }
- virtual char *ptsname () { return NULL;}
+ virtual int ptsname_r (char *, size_t);
virtual class fhandler_socket *is_socket () { return NULL; }
virtual class fhandler_console *is_console () { return 0; }
virtual int is_windows () {return 0; }
@@ -1486,7 +1486,7 @@ public:
int tcflush (int);
int ioctl (unsigned int cmd, void *);
- char *ptsname ();
+ int ptsname_r (char *, size_t);
bool hit_eof ();
bool setup ();
diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc
index a8a56598e..c68211b66 100644
--- a/winsup/cygwin/fhandler_tty.cc
+++ b/winsup/cygwin/fhandler_tty.cc
@@ -1419,13 +1419,19 @@ fhandler_pty_master::ioctl (unsigned int cmd, void *arg)
return 0;
}
-char *
-fhandler_pty_master::ptsname ()
+int
+fhandler_pty_master::ptsname_r (char *buf, size_t buflen)
{
- static char buf[TTY_NAME_MAX];
+ char tmpbuf[TTY_NAME_MAX];
- __small_sprintf (buf, "/dev/pty%d", get_unit ());
- return buf;
+ __small_sprintf (tmpbuf, "/dev/pty%d", get_unit ());
+ if (buflen <= strlen (tmpbuf))
+ {
+ set_errno (ERANGE);
+ return ERANGE;
+ }
+ strcpy (buf, tmpbuf);
+ return 0;
}
void
diff --git a/winsup/cygwin/include/cygwin/stdlib.h b/winsup/cygwin/include/cygwin/stdlib.h
index edf00a073..d2dfe4cbc 100644
--- a/winsup/cygwin/include/cygwin/stdlib.h
+++ b/winsup/cygwin/include/cygwin/stdlib.h
@@ -30,6 +30,7 @@ long random (void);
char *setstate (const char *state);
void srandom (unsigned);
char *ptsname (int);
+int ptsname_r(int, char *, size_t);
int grantpt (int);
int unlockpt (int);
#endif /*__STRICT_ANSI__*/
diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include/cygwin/version.h
index 27dccf27c..db9a18b4d 100644
--- a/winsup/cygwin/include/cygwin/version.h
+++ b/winsup/cygwin/include/cygwin/version.h
@@ -423,12 +423,13 @@ details. */
252: CW_CVT_ENV_TO_WINENV added.
253: Export TIOCSCTTY, tcgetsid.
254: Export getgrouplist.
+ 255: Export ptsname_r.
*/
/* Note that we forgot to bump the api for ualarm, strtoll, strtoull */
#define CYGWIN_VERSION_API_MAJOR 0
-#define CYGWIN_VERSION_API_MINOR 254
+#define CYGWIN_VERSION_API_MINOR 255
/* There is also a compatibity version number associated with the
shared memory regions. It is incremented when incompatible
diff --git a/winsup/cygwin/pinfo.cc b/winsup/cygwin/pinfo.cc
index 26739ddbe..ea30293ba 100644
--- a/winsup/cygwin/pinfo.cc
+++ b/winsup/cygwin/pinfo.cc
@@ -975,10 +975,10 @@ _pinfo::dup_proc_pipe (HANDLE hProcess)
}
/* function to set up the process pipe and kick off proc_waiter */
-int
+bool
pinfo::wait ()
{
- /* If rd_proc_pipe that means we're in an execed process which already has
+ /* If rd_proc_pipe != NULL we're in an execed process which already has
grabbed the read end of the pipe from the previous cygwin process running
with this pid. */
if (!rd_proc_pipe)
@@ -989,13 +989,13 @@ pinfo::wait ()
{
system_printf ("Couldn't create pipe tracker for pid %d, %E",
(*this)->pid);
- return 0;
+ return false;
}
if (!(*this)->dup_proc_pipe (hProcess))
{
system_printf ("Couldn't duplicate pipe topid %d(%p), %E", (*this)->pid, hProcess);
- return 0;
+ return false;
}
}
@@ -1013,7 +1013,7 @@ pinfo::wait ()
(*this)->pid, (*this)->dwProcessId, rd_proc_pipe);
}
- return 1;
+ return true;
}
void
diff --git a/winsup/cygwin/pinfo.h b/winsup/cygwin/pinfo.h
index a69316148..b43f03a9b 100644
--- a/winsup/cygwin/pinfo.h
+++ b/winsup/cygwin/pinfo.h
@@ -153,7 +153,7 @@ public:
pinfo (pid_t n, DWORD flag) : rd_proc_pipe (NULL), hProcess (NULL), waiter_ready (0), wait_thread (NULL) {init (n, flag, NULL);}
void thisproc (HANDLE) __attribute__ ((regparm (2)));
void release ();
- int wait () __attribute__ ((regparm (1)));
+ bool wait () __attribute__ ((regparm (1)));
~pinfo ()
{
if (destroy && procinfo)
@@ -173,6 +173,7 @@ public:
operator _pinfo * () const {return procinfo;}
void preserve () { destroy = false; }
#ifndef _SIGPROC_H
+ int reattach () {system_printf ("reattach is not here"); return 0;}
int remember () {system_printf ("remember is not here"); return 0;}
#else
int reattach ()
diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc
index f31081044..911d5cba0 100644
--- a/winsup/cygwin/sigproc.cc
+++ b/winsup/cygwin/sigproc.cc
@@ -866,7 +866,7 @@ child_info_spawn::reattach_children ()
false, DUPLICATE_SAME_ACCESS))
debug_printf ("couldn't duplicate parent %p handles for forked children after exec, %E",
children[i].rd_proc_pipe);
- else if (!(p.hProcess = OpenProcess (PROCESS_QUERY_INFORMATION, false, p->pid)))
+ else if (!(p.hProcess = OpenProcess (PROCESS_QUERY_INFORMATION, false, p->dwProcessId)))
CloseHandle (p.rd_proc_pipe);
else if (!p.reattach ())
{
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index 5bfaa0c08..514d458fd 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -2906,10 +2906,23 @@ getpgrp (void)
extern "C" char *
ptsname (int fd)
{
+ static char buf[TTY_NAME_MAX];
+ return ptsname_r (fd, buf, sizeof (buf)) == 0 ? buf : NULL;
+}
+
+extern "C" int
+ptsname_r (int fd, char *buf, size_t buflen)
+{
+ if (!buf)
+ {
+ set_errno (EINVAL);
+ return EINVAL;
+ }
+
cygheap_fdget cfd (fd);
if (cfd < 0)
return 0;
- return (char *) (cfd->ptsname ());
+ return cfd->ptsname_r (buf, buflen);
}
static int __stdcall