From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <4A116D6D.7020105@domain.hid> Date: Mon, 18 May 2009 16:15:09 +0200 From: Jan Kiszka MIME-Version: 1.0 References: <4A116AC5.7010704@domain.hid> In-Reply-To: <4A116AC5.7010704@domain.hid> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Xenomai-help] select(2) generates EFAULT List-Id: Help regarding installation and common use of Xenomai List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gilles Chanteperdrix Cc: xenomai@xenomai.org Gilles Chanteperdrix wrote: > Steve wrote: >> First, thank you for the help on my previous query. >> >> I am still working on porting a c++ application from RTAI to Xenomai, >> and have encountered a problem with sockets, specifically the select >> function. >> >> When Xenomai is not being used the code runs as expected. Once the >> Xenomai headers, compile options, etc, are used the select function >> fails with the error EFAULT. I have reproduced the error (works >> without Xenomai, EFAULTs with Xenomai) using the following program: >> >> #include >> #include >> #include >> >> int handleError(char *msg, int err); >> >> int main(void) >> { >> int sfd; >> struct sockaddr_in sai; >> fd_set SockSet; >> struct timeval tv; >> tv.tv_sec = 2; >> tv.tv_usec = 0; >> >> sai.sin_family = AF_INET; >> sai.sin_port = htons(1025); >> sai.sin_addr.s_addr = htonl(INADDR_ANY); >> >> if((sfd = socket(AF_INET, SOCK_STREAM, 0)) == -1) >> { return handleError("creation error", errno); } >> >> if(bind(sfd, (struct sockaddr*)&sai, sizeof(sai)) == -1) >> { return handleError("bind error", errno); } >> >> if(listen(sfd, 5) == -1) >> { return handleError("listen error", errno); } >> >> FD_ZERO(&SockSet); >> FD_SET(sfd, &SockSet); >> >> if(select(sfd+1, &SockSet, 0, 0, &tv) == -1) >> { return handleError("select error", errno); } >> >> printf("success\n"); >> >> return 0; >> } >> >> I am using Xenomai 2.4.6.1 on a vanilla 2.6.24.6 Linux kernel, and >> running on Ubuntu 8.04. > > Could you try 2.4.7, to see if you are not having a bug which has > already been fixed? > > What you are trying should work, even though you are not really using > Xenomai's select but Linux plain select. This should have been fixed in 2.4.x.git - if my patch were applied. See git://git.xenomai.org/xenomai-jki.git for-2.4.x Did I missed to post some correction of that version, or what delays this? Sorry, lost track of it. Jan -- Siemens AG, Corporate Technology, CT SE 2 Corporate Competence Center Embedded Linux