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>
This commit is contained in:
Corinna Vinschen 2019-01-05 21:42:33 +01:00
parent a3a5d52b39
commit 97d2fe2694
1 changed files with 11 additions and 4 deletions

View File

@ -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);