Re: Get number of bytes available in PeekNamedPipe (take 2)
Uwe Bonnes <bon(a)elektron.ikp.physik.tu-darmstadt.de> writes:
As I don't have a test target, I don't feel yet like filling lpvBuffer and I don't yet have an idea how to do that. I looked at the kernel sources and lseek unconditionally returns error on pipe. So how can we read the pipe and get the filepointer back to the original position afterwards?
You can't use lseek, you have to make the pipe a socket pair and use recv(MSG_PEEK).
wine/server/protocol.def Define a FD_TYPE_PIPE wine/server/file.c: get_handle_fd On type FD_TYPE_PIPE check other end of type
If this is really necessary it should be done on the client side. I'm not sure I see the point though. -- Alexandre Julliard julliard(a)winehq.com
"Alexandre" == Alexandre Julliard <julliard(a)winehq.com> writes:
Alexandre> Uwe Bonnes <bon(a)elektron.ikp.physik.tu-darmstadt.de> writes: >> As I don't have a test target, I don't feel yet like filling >> lpvBuffer and I don't yet have an idea how to do that. I looked at >> the kernel sources and lseek unconditionally returns error on >> pipe. So how can we read the pipe and get the filepointer back to the >> original position afterwards? Alexandre> You can't use lseek, you have to make the pipe a socket pair Alexandre> and use recv(MSG_PEEK). >> wine/server/protocol.def Define a FD_TYPE_PIPE wine/server/file.c: >> get_handle_fd On type FD_TYPE_PIPE check other end of type Alexandre> If this is really necessary it should be done on the client Alexandre> side. I'm not sure I see the point though. PeekNamedPipe must report when the pipe is broken, otherwise some programs wait forever for a message from the already disappeared program. Without checking for a broken other end, FIONREAD always reports "0 bytes". I don't see how I can doi that on the client side, beside exporting the pipe(_user)_get_fd functions directly. Programming hints are welcome. Bye -- Uwe Bonnes bon(a)elektron.ikp.physik.tu-darmstadt.de Institut fuer Kernphysik Schlossgartenstrasse 9 64289 Darmstadt --------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------
Uwe Bonnes <bon(a)elektron.ikp.physik.tu-darmstadt.de> writes:
PeekNamedPipe must report when the pipe is broken, otherwise some programs wait forever for a message from the already disappeared program. Without checking for a broken other end, FIONREAD always reports "0 bytes". I don't see how I can doi that on the client side, beside exporting the pipe(_user)_get_fd functions directly. Programming hints are welcome.
OK, I was thinking this would be checked in read(), but I guess the app may never call read() if PeekNamedPipe returns 0 available bytes. You should be able to check for a closed pipe using poll() and testing for POLLHUP. -- Alexandre Julliard julliard(a)winehq.com
participants (2)
-
Alexandre Julliard -
Uwe Bonnes