[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [CPROG] fd / fcntl / ioctl mm



Hej jag löste problemet, men inte på det viset som jag ville. Så här
gjorde jag.

Först sätter jag pipen till blockerande om det inte finns någon data att
läsa.

temp=fcntl(fd_read, F_GETFL,0);
if(temp==-1) out("Error fcntl fd *** %s\n", strerror(errno));
if(temp!=-1){
   temp &= ~O_NDELAY;
   if(fcntl(fd_read, F_SETFL, temp)==-1) out("Error fcntl fd *** 
%s\n",strerror(errno));
}

Sedan skrev jag en funktion som läser in tills den hittar terminerings
tecknet. I övrigt så fungerar den som read. 

int Read(int fd, char *buf, int count, char term)
{
  int counter=0;
  char c;

  do{
    read(fd, &c, 1);
    buf[counter] = c;
    counter++;
  } while(c != term && counter < count);

  if(counter != count) buf[counter] = 0;

  return counter;
} 

Resultatet blir samma som jag ville komma åt.

mvh
  Martin Bertilsson Haagen



 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 20:08 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *