delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/08/27/04:38:52

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-ID: <007001c24da6$858b3d40$0b01a8c0@Camelot>
From: "Pierluigi 'Lanugo' Rolando" <lanugo AT ica-net DOT it>
To: "Cygwin" <cygwin AT cygwin DOT com>
Subject: Help with unix sockets and poll
Date: Tue, 27 Aug 2002 10:35:35 +0200
MIME-Version: 1.0
X-Priority: 3
X-MSMail-Priority: Normal
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400
Note-from-DJ: This may be spam

------=_NextPart_000_0036_01C24DB5.7A0EBA00
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

Hi,
I've tried to port some code that relies heavily on unix domain sockets for
IPC from Linux to Cygwin, and I've encountered some problems. It seems that
either unix domain sockets (created by socketpair() ) or the poll() library
call are broken.
I'm attaching the smallest test case I've been able to write that reproduces
the problem. Under linux (2.4.19/2.4.18 w/ glibc 2.2.4) the program
terminates correctly, while under cygwin it reports a POLLERR after the
first character is written on the socket. My cygwin DLL is version
1.3.12-cygwin-1-3-12-1, and gcc -v reports "Reading specs from
/usr/lib/gcc-lib/i686-pc-cygwin/2.95.3-5/specs | gcc version 2.95.3-5
(cygwin special)". I've done some researching on the net in order to find
out whethere I'm the first to experience this problem, and I haven't found
anything.

I've also downloaded and quickly checked the winsup sources, but I really
don't know Cygwin enough to be able to debug its sources (moreover, it could
be a flaw in my code).

Sorry for my bad english and thank you for you patience,
P. Rolando aka Lanugo of the Wandering Souls



------=_NextPart_000_0036_01C24DB5.7A0EBA00
Content-Type: application/octet-stream;
	name="ubug.c"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename="ubug.c"

#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <sys/poll.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <stdio.h>

int main(void)
{
	int ss[2];
	int i, j;
	struct pollfd pfd[2];
	char str[] = "w";

	if(socketpair(PF_UNIX, SOCK_STREAM, 0, ss) != 0) {
		fprintf(stderr, "socketpair: failed\n");
		return 1;
	}

	for(i = 0; i < 2; ++i)
		pfd[i].fd = ss[i];

	for(j = 0; j < 10; ++j) {
		for(i = 0; i < 2; ++i) {
			pfd[i].events = (POLLIN | POLLOUT);
		}

		poll(pfd, 2, -1);

		for(i = 0; i < 2; ++i)
			if(pfd[i].revents & POLLERR) {
				fprintf(stderr, "POLLERR: %d\n", pfd[i].fd);
				return 1;
			}

		if(pfd[0].revents & POLLOUT) {
			send(pfd[0].fd, (void *)str, 1, 0);
			fprintf(stderr, "w");
		}

		if(pfd[1].revents & POLLIN) {
			char buffer[1024];
			recv(pfd[1].fd, buffer, sizeof(buffer), 0);
			printf("W");
		}
	}

	return 0;
}


------=_NextPart_000_0036_01C24DB5.7A0EBA00
Content-Type: text/plain; charset=us-ascii

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/
------=_NextPart_000_0036_01C24DB5.7A0EBA00--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019