[newlib-cygwin] Cygwin: pipe: use /proc/PID/fd/... or /proc/self/fd/... name
Corinna Vinschen
corinna@sourceware.org
Sun Jan 6 19:41:00 GMT 2019
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=97d2fe2694ce935bc295ad6107ce9c7de55285b8
commit 97d2fe2694ce935bc295ad6107ce9c7de55285b8
Author: Corinna Vinschen <corinna@vinschen.de>
Date: Sat Jan 5 21:42:33 2019 +0100
Cygwin: pipe: use /proc/PID/fd/... or /proc/self/fd/... name
Don't emit /dev/fd/... filename. This simplifies pipe path handling
and avoids another symlink redirection.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diff:
---
winsup/cygwin/pipe.cc | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/winsup/cygwin/pipe.cc b/winsup/cygwin/pipe.cc
index f1eace6..a75275d 100644
--- a/winsup/cygwin/pipe.cc
+++ b/winsup/cygwin/pipe.cc
@@ -73,8 +73,15 @@ fhandler_pipe::open (int flags, mode_t mode)
bool inh;
bool got_one = false;
- sscanf (get_name (), "/proc/%d/fd/pipe:[%lld]",
- &pid, (long long *) &uniq_id);
+ if (sscanf (get_name (), "/proc/self/fd/pipe:[%lld]",
+ (long long *) &uniq_id) == 1)
+ pid = myself->pid;
+ else if (sscanf (get_name (), "/proc/%d/fd/pipe:[%lld]",
+ &pid, (long long *) &uniq_id) < 2)
+ {
+ set_errno (ENOENT);
+ return 0;
+ }
if (pid == myself->pid)
{
cygheap_fdenum cfd (true);
@@ -439,8 +446,8 @@ pipe_worker (int filedes[2], unsigned int psize, int mode)
{
cygheap_fdnew fdin;
cygheap_fdnew fdout (fdin, false);
- char buf[sizeof ("/dev/fd/pipe:[9223372036854775807]")];
- __small_sprintf (buf, "/dev/fd/pipe:[%D]", fhs[0]->get_plain_ino ());
+ char buf[sizeof ("/proc/self/fd/pipe:[9223372036854775807]")];
+ __small_sprintf (buf, "/proc/self/fd/pipe:[%D]", fhs[0]->get_plain_ino ());
fhs[0]->pc.set_posix (buf);
__small_sprintf (buf, "pipe:[%D]", fhs[1]->get_plain_ino ());
fhs[1]->pc.set_posix (buf);
More information about the Cygwin-cvs
mailing list