Cygwin: proc fd: fix handling of pipes, sockets, etc

The symlink target of /proc/PID/fd files pointing to pipes and
sockets are just artificial filenames referencing the object using
some internal number.  The pipe open code expects a path specifying
process pid and the internal number so it access the right process
and pipe.

- Set the posix path of the pipe to the simple pipe name only,
  as it shows up in /proc/PID/fd.  A /proc/self prefix is just
  as wrong as a /dev/fd prefix.

- Revert thinko in fhandler_pipe::open expecting the name as
  /proc/self/fd/...  In fact this should never happen.

- Fix up the path before re-opening the pipe instead.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen
2019-02-05 15:32:08 +01:00
parent b59f5795e6
commit 5628399c84
3 changed files with 15 additions and 7 deletions

View File

@@ -5061,8 +5061,8 @@ pipe_worker (int filedes[2], unsigned int psize, int mode)
{
cygheap_fdnew fdin;
cygheap_fdnew fdout (fdin, false);
char buf[sizeof ("/proc/self/fd/pipe:[9223372036854775807]")];
__small_sprintf (buf, "/proc/self/fd/pipe:[%D]", fhs[0]->get_plain_ino ());
char buf[sizeof ("pipe:[9223372036854775807]")];
__small_sprintf (buf, "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);