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:
		| @@ -13,6 +13,7 @@ details. */ | ||||
| #include "pinfo.h" | ||||
| #include "dtable.h" | ||||
| #include "cygheap.h" | ||||
| #include "tls_pbuf.h" | ||||
|  | ||||
| fhandler_base * | ||||
| fhandler_process_fd::fetch_fh (HANDLE &out_hdl, uint32_t flags) | ||||
| @@ -86,6 +87,16 @@ fhandler_process_fd::fetch_fh (HANDLE &out_hdl, uint32_t flags) | ||||
|       CloseHandle (hdl); | ||||
|       return NULL; | ||||
|     } | ||||
|   /* relative path?  This happens for special types like pipes and sockets. */ | ||||
|   if (*pc.get_posix () != '/') | ||||
|     { | ||||
|       tmp_pathbuf tp; | ||||
|       char *fullpath = tp.c_get (); | ||||
|  | ||||
|       stpcpy (stpncpy (fullpath, get_name (), path - get_name ()), | ||||
| 	      pc.get_posix ()); | ||||
|       pc.set_posix (fullpath); | ||||
|     } | ||||
|   fhandler_base *fh = build_fh_pc (pc); | ||||
|   if (!fh) | ||||
|     { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user