in reply to Re: Select on STDIN or ALARM?! For Win32 doesn't work!
in thread Select on STDIN or ALARM?! For Win32 doesn't work!

Dis you test your code?! I made some tests for Thread too, but all the process stop when reading STDIN!!! :-/

Test Thread:

use threads; use threads::shared; my ($BUFFER) : shared ; $thra = threads->new(\&read_stdin); $thrb = threads->new(\&send_sock); print "By!\n" ; ############## # READ_STDIN # ############## sub read_stdin { 1 while( read( \*STDIN , $BUFFER, 1 , length($BUFFER) ) ) ; } ############# # SEND_SOCK # ############# sub send_sock { my ($buf_lng) ; for(;;) { if ( length($BUFFER) > $buf_lng ) { my $buf = substr($BUFFER , $buf_lng-1 ) ; print "<$buf>\n" ; } $buf_lng = length($BUFFER) ; print ".\n" ; sleep(1) ; } }
But thanks for the reply!

Graciliano M. P.
"The creativity is the expression of the liberty".

Replies are listed 'Best First'.
Re: Re: Re: Select on STDIN or ALARM?! For Win32 doesn't work!
by pg (Canon) on Dec 27, 2002 at 21:27 UTC
    Of course, I tested my code before I post it. Before you question whether I tested my code, you better try my code out first. Everyone should only speak base on facts, not guesses.

    Your threaded code does not work, does not imply all threaded code do not work.

    But I will be happy to look into your code, and see why it is stuck. I will do this now.

    Still looking at your code... First your code exited right after I started it. Reason? simple, because after it created two child threads, your main thread just print "bye" and exit. How did you test your code? I will add joins before bye.

    ...

    Okay, tested your code. It died on you? Sorry it worked for me, after added:
    threads::join($thra); threads::join($thrb);
    Couple of things about your code:
    1. You use $BUFFER without check whether it is undef, that causes lots of warning, when you do length($BUFFER) etc.
    2. You better lock your shared variables before update them, although in your context, this not that serious a problem
      Yes your code works! Sorry!

      the error that I found in my code is the $|, that is only flushed for the main thread for default when you run from console!

      Thanks for the help! ;-P

      Graciliano M. P.
      "The creativity is the expression of the liberty".