in reply to Read from a Linux pipe hangs.
#!/usr/bin/perl -w # producer.pl use strict; while(1){ syswrite(STDOUT,"Hello\n",length("Hello\n")); sleep(2); }
Hope this helps ;-)#!/usr/bin/perl -w # consumer.pl use strict; my $line; while ($line = <STDIN>){ print "$line"; } =pod my $line; my $buf; while (sysread(STDIN,$buf,1)){ if ($buf =~ /\n|\r|\r\n/o){ print "$line\n"; $line = ""; }else{ $line.=$buf; } } =cut
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Read from a Linux pipe hangs.
by dmor4477 (Initiate) on Feb 23, 2005 at 20:18 UTC | |
by Ultra (Hermit) on Feb 24, 2005 at 07:44 UTC | |
by dmor4477 (Initiate) on Feb 24, 2005 at 12:06 UTC | |
by Ultra (Hermit) on Feb 24, 2005 at 12:24 UTC | |
by dmor4477 (Initiate) on Feb 24, 2005 at 12:24 UTC |