[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: [PROGRAMMERING] perl non-blocking STDIN



On Fri, 2005-10-07 at 22:05 +0200, Carsten Svaneborg wrote:
> Hej!
> 
> Jeg vil gerne læse STDIN linie for linie,
> men non-blocking så jeg kan udføre noget
> kode i baggrunden, er der nogen let måde at
> gøre dette på?

select RBITS,WBITS,EBITS,TIMEOUT
               This calls the select(2) system call with the bit masks
speci-
               fied, which can be constructed using "fileno" and "vec",
along
               these lines:

                   $rin = $win = $ein = '';
                   vec($rin,fileno(STDIN),1) = 1;
                   vec($win,fileno(STDOUT),1) = 1;
                   $ein = $rin | $win;

Jeg har aldrig prøvet det med Perl, kun C, men det skulle fungerer på
samme måde.

Sæt TIMEOUT til 0 og test så om der kom noget på STDIN, hvis nej så kør
anden kode.

/hans



 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-11-01, 02:01 CET [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] *