From 97d2fe2694ce935bc295ad6107ce9c7de55285b8 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Sat, 5 Jan 2019 21:42:33 +0100 Subject: [PATCH] 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 --- 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 f1eace6a6..a75275d7c 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);