[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
 

Read & Strängslut



Hej

Jag jobbar förnärvarande med ett program som läser och skriver till
fildesciptors. Processessen har forkat några gånger och pratar med sina
"childs" genom pipes. Det uppstår här ett litet problem, eftersom strängen kan
vara hur lång som hälst så allocerar jag mera minne när det behövs. Detta gör
jag med följande rutin:
-------------------
	struct ReadStruct{
		char Data[1025];
		struct ReadStruct *Next;
	}

	do{
		Item=(struct ReafStruct *) malloc(sizeof(ReadStruct));
		/*
		 * Lite kod som sköter den länkade-listan
		 */
(1)		temp=read(fd,Item->Data,1024);
	} while (temp==1024);
---------------------

Koden funkar bra. Det finns tre olika möjligheter här; 
1. strängen > 1024 tecken
2. strängen < 1024 tecken
3. strängen = 1024 tecken

De två första tillfällena funkar fint. Men om strängen blir exact 1024 tecken
lång så fastnar vi på raden som markerats med (1). 
Jag behöver altså kontrollera om fd är tom, men jag vet inte hur man gör detta.
Det finns ju en möjlighet till det är att man på något sätt sätter ändra fd så
att den inte är blockerande längre men jag vet inte om detta är möjligt eller
hur man gör det.

Någon som kan hjälpa mig? 
	


-- 
mvh
 Martin Bertilsson Haagen
______________________________________________________________
	sslug@sslug, 0707/671717
	http://www.geocities.com/SiliconValley/Sector/5700/
______________________________________________________________


 
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] *