aboutsummaryrefslogtreecommitdiff
path: root/winsup
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2005-02-01 16:43:29 +0000
committerCorinna Vinschen <corinna@vinschen.de>2005-02-01 16:43:29 +0000
commit01a94cf8662ffe333b0b75fc98aa44ada4320aeb (patch)
tree59d3c34e948fdeda77e0495f7c30821b444681ec /winsup
parente8309efda5499f88eb950ff652acdd3a6b07d678 (diff)
downloadnewlib-01a94cf8662ffe333b0b75fc98aa44ada4320aeb.zip
newlib-01a94cf8662ffe333b0b75fc98aa44ada4320aeb.tar.gz
newlib-01a94cf8662ffe333b0b75fc98aa44ada4320aeb.tar.bz2
* pipe.cc (fhandler_pipe::open): Allow re-opening of /proc/<pid>/fd
pipes of the current process.
Diffstat (limited to 'winsup')
-rw-r--r--winsup/cygwin/ChangeLog5
-rw-r--r--winsup/cygwin/pipe.cc33
2 files changed, 38 insertions, 0 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 465b071..7a0cb6d 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,5 +1,10 @@
2005-02-01 Corinna Vinschen <corinna@vinschen.de>
+ * pipe.cc (fhandler_pipe::open): Allow re-opening of /proc/<pid>/fd
+ pipes of the current process.
+
+2005-02-01 Corinna Vinschen <corinna@vinschen.de>
+
* fhandler.cc (fhandler_base::get_proc_fd_name): Don't generate
"device:" entry.
* fhandler.h (fhandler_socket::open): New method.
diff --git a/winsup/cygwin/pipe.cc b/winsup/cygwin/pipe.cc
index 988ee57..6ce5406 100644
--- a/winsup/cygwin/pipe.cc
+++ b/winsup/cygwin/pipe.cc
@@ -38,6 +38,39 @@ fhandler_pipe::fhandler_pipe ()
int
fhandler_pipe::open (int flags, mode_t mode)
{
+ const char *path = get_name ();
+ debug_printf ("path: %s", path);
+ if (!strncmp (get_name (), "/proc/", 6))
+ {
+ char *c;
+ HANDLE hdl;
+ int pid = strtol (path += 6, &c, 10);
+ if (!pid || !c || *c != '/')
+ goto out;
+ path = c;
+ if (strncmp (path, "/fd/pipe:[", 10))
+ goto out;
+ path += 10;
+ hdl = (HANDLE) atoi (path);
+ if (pid == myself->pid)
+ {
+ cygheap_fdenum cfd;
+ while (cfd.next () >= 0)
+ {
+ if (cfd->get_handle () == hdl)
+ {
+ if (!cfd->dup (this))
+ return 1;
+ return 0;
+ }
+ }
+ }
+ else
+ {
+ /* TODO: Open pipes of different process. Is that possible? */
+ }
+ }
+out:
set_errno (ENXIO);
return 0;
}