]> sourceware.org Git - newlib-cygwin.git/commitdiff
* pipe.cc (fhandler_pipe::open): Allow re-opening of /proc/<pid>/fd
authorCorinna Vinschen <corinna@vinschen.de>
Tue, 1 Feb 2005 16:43:29 +0000 (16:43 +0000)
committerCorinna Vinschen <corinna@vinschen.de>
Tue, 1 Feb 2005 16:43:29 +0000 (16:43 +0000)
pipes of the current process.

winsup/cygwin/ChangeLog
winsup/cygwin/pipe.cc

index 465b0716c2e1bd72b2669b7cf82805c660b02bcd..7a0cb6d00bba9ca3222a8fc44525e50af0e9e60b 100644 (file)
@@ -1,3 +1,8 @@
+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
index 988ee5731b501874069bc7f9eef7754dae43d20d..6ce5406959cd811d4c6ddc3931c8002d084157cd 100644 (file)
@@ -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;
 }
This page took 0.034894 seconds and 5 git commands to generate.