Use poll in PeekNamedPipe
Uwe Bonnes
bon at elektron.ikp.physik.tu-darmstadt.de
Fri Aug 2 19:23:57 CDT 2002
Changelog:
dlls/kernel/sync.c: PeeknamedPipe
Use poll() to see if pipe is still alife
We probably need to check with configure whether we have poll(). However I
go out to vacation and want to get this part out before. With this patch and
native msvcrt, I can run processes from the Xilinx Webpack "Processes for
Current Source" window.
Bye
--
Uwe Bonnes bon at elektron.ikp.physik.tu-darmstadt.de
Institut fuer Kernphysik Schlossgartenstrasse 9 64289 Darmstadt
--------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------
Index: wine/dlls/kernel/sync.c
===================================================================
RCS file: /home/wine/wine/dlls/kernel/sync.c,v
retrieving revision 1.22
diff -u -r1.22 sync.c
--- wine/dlls/kernel/sync.c 31 Jul 2002 20:04:20 -0000 1.22
+++ wine/dlls/kernel/sync.c 3 Aug 2002 00:17:22 -0000
@@ -26,6 +26,7 @@
#ifdef HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
#endif
+#include <sys/poll.h>
#include "winbase.h"
#include "winerror.h"
@@ -37,7 +38,7 @@
#include "wine/debug.h"
-WINE_DEFAULT_DEBUG_CHANNEL(win32);
+WINE_DEFAULT_DEBUG_CHANNEL(pipe);
/*
* Events
@@ -538,16 +539,40 @@
{
#ifdef FIONREAD
int avail=0,fd;
+ struct pollfd pollfd;
fd = FILE_GetUnixHandle(hPipe, GENERIC_READ);
if (fd == -1)
return FALSE;
- /* On linux fstat on pipes doesn't work */
- if (ioctl(fd,FIONREAD, &avail ) != 0)
+ pollfd.fd = fd;
+ pollfd.events = POLLIN;
+ pollfd.revents = 0;
+ switch (poll(&pollfd, 1, 0))
{
- TRACE("FIONREAD failed reason: %s\n",strerror(errno));
- close(fd);
- return FALSE;
+ case 1:
+ /* got something */
+ if (pollfd.revents & (POLLHUP | POLLERR))
+ {
+ /* pipe is broken */
+ TRACE("POLLHUP | POLLERR\n");
+ goto error;
+ }
+ else
+ {
+ /* On linux fstat on pipes doesn't work */
+ if (ioctl(fd,FIONREAD, &avail ) != 0)
+ {
+ TRACE("FINOREAD failed reason: %s\n",strerror(errno));
+ goto error;
+ }
+ }
+ break;
+ case 0:
+ break;
+ case -1:
+ TRACE("handle 0x%08x fd 0x%08x poll failed: %s\n",
+ hPipe, fd, strerror(errno));
+ goto error;
}
close(fd);
TRACE(" 0x%08x bytes available\n", avail );
@@ -556,6 +581,16 @@
*lpcbAvail= avail;
return TRUE;
}
+ else
+ {
+ SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+ FIXME("function not implemented\n");
+ return FALSE;
+ }
+ error:
+ close(fd);
+ SetLastError(ERROR_BROKEN_PIPE);
+ return FALSE;
#endif /* defined(FIONREAD) */
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
More information about the wine-patches
mailing list