diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2019-01-05 21:42:33 +0100 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2019-01-05 21:42:33 +0100 |
commit | 97d2fe2694ce935bc295ad6107ce9c7de55285b8 (patch) | |
tree | add634eda26b4331d0cf2384dfedec174c54973e | |
parent | a3a5d52b398887a5ee1ca75b23915d17a60ac10a (diff) | |
download | cygnal-97d2fe2694ce935bc295ad6107ce9c7de55285b8.tar.gz cygnal-97d2fe2694ce935bc295ad6107ce9c7de55285b8.tar.bz2 cygnal-97d2fe2694ce935bc295ad6107ce9c7de55285b8.zip |
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>
-rw-r--r-- | winsup/cygwin/pipe.cc | 15 |
1 files 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); |