[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] Flushing af stdin



In article <sslug@sslug> you wrote:

> Kunne en eller anden venlig sjæl fortælle mig, hvordan man flusher stdin.
> Jeg læser med et bestemt interval det første tegn fra stdin. Derefter vil
> jeg gerne flushe den.

Hvis det nu var en speciel I/O fra termios, så kan du bruge tcflush :
(se manual siderne)
       tcflush() discards data written to the object referred  to
       by  fd but not transmitted, or data received but not read,
       depending on the value of queue_selector:

Men det vil kun virke for input fra disse enheder, ikke stdin.
stdin kommer jo måske fra en fil, så "flush" vil jo give eof :

  mitprog < mitinput


Alternativ så brug select() og read() og blive ved at kalde indtil der 
i en given tid ikke kommer mere input (select kan kaldes med timeout).


-- 
mvh Frank Damgaard  | http://home3.inet.tele.dk/frda/



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