Leser: 2
|< 1 2 3 4 >| | 34 Einträge, 4 Seiten |
1
2
3
4
5
6
7
8
9
10
11
12
use IO::Select;
open my $file, '<', 'tail' or die $!;
my $select = IO::Select->new( $file );
while (my @ready = $select->can_read ) {
for my $fh (@ready) {
while ( sysread $fh, my $buff, 100 ) {
syswrite STDOUT, $buff;
}
}
}
close $file;
1
2
3
4
5
6
7
open my $file, '<', 'tail' or die $!;
while (1) {
while ( sysread $file, my $buff, 100 ) {
syswrite STDOUT, $buff;
}
}
close $file;
1
2
3
4
5
6
7
8
9
10
fstat(3,0xbfbfdde0) = 0 (0x0)
break(0x8050000) = 0 (0x0)
lseek(3,0x0,SEEK_CUR) = 0 (0x0)
lseek(3,0x0,SEEK_SET) = 0 (0x0)
read(0x3,0x804f000,0x1000) = 487 (0x1e7)
munmap(0x28159000,0x1e7) = 0 (0x0)
read(0x3,0x804f000,0x1000) = 0 (0x0)
kqueue() = 4 (0x4)
fstatfs(0x3,0xbfbfde20) = 0 (0x0)
kevent(0x4,0x804d080,0x1,0x0,0x0,0xbfbfde18) = 0 (0x0)
1
2
3
4
nanosleep(0xFFBFF188, 0xFFBFF180) = 0
read(0, 0x00024718, 65537) = 0
nanosleep(0xFFBFF188, 0xFFBFF180) = 0
read(0, 0x00024718, 65537) = 0
Quoteunter windows funzt dein script kein stück.
es word nichtmal die datei ausgegeben.
QuoteUnd das Programm wartet. Hier gibt es also einen speziellen "kernel event notification mechanism". Linux hat bestimmt etwas Ähnliches, oder verwendet eben auch nur den sleep 0.1-Workaround. Schau mal mit strace rein.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
write(1, "foofoofoofoobarbarbarbartesttest"..., 75foofoofoofoobarbarbarbartesttesttesttesttesttestblubblubhkjhblablablablabla) = 75
nanosleep({1, 0}, NULL) = 0
fstat64(3, {st_mode=S_IFREG|0644, st_size=208, ...}) = 0
nanosleep({1, 0}, NULL) = 0
fstat64(3, {st_mode=S_IFREG|0644, st_size=208, ...}) = 0
nanosleep({1, 0}, NULL) = 0
fstat64(3, {st_mode=S_IFREG|0644, st_size=208, ...}) = 0
nanosleep({1, 0}, NULL) = 0
fstat64(3, {st_mode=S_IFREG|0644, st_size=208, ...}) = 0
nanosleep({1, 0}, NULL) = 0
fstat64(3, {st_mode=S_IFREG|0644, st_size=208, ...}) = 0
nanosleep({1, 0}, NULL) = 0
fstat64(3, {st_mode=S_IFREG|0644, st_size=208, ...}) = 0
nanosleep({1, 0}, <unfinished ...>
1
2
3
4
5
6
7
8
9
open( my $FH, "<", $filename )
or die "Error: couldn't open file '$filename': $!\n";
while( 1 ) {
while( my $line = <$FH> ) {
print $line;
}
sleep 1;
seek( $FH, 0, 1 );
} # while 1
1
2
3
4
5
6
7
while( 1 ) {
while( my $line = <$FH> ) {
print $line;
}
sleep 1;
$FH->clearerr();
} # while 1
|< 1 2 3 4 >| | 34 Einträge, 4 Seiten |