4 Einträge, 1 Seite |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/perl
$| = 1;
$x = 0;
$pid1 = fork;
unless ($pid1)
{
sleep (3);
$x = 1;
exit;
};
while ($x == 0)
{
print ".";
select(undef, undef, undef, 0.02);
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
use IO::Select;
print "($$) parent\n";
$| = 1;
my $timeout = 1;
if ( my $pid = open my $fh, "-|" ) {
print "($$) opened $pid\n";
my $s = IO::Select->new;
$s->add($fh);
my $ready;
while (not(($ready) = $s->can_read($timeout))) {
print ".";
}
print $/;
chomp, print "($$) got ($_) from child\n" while <$ready>;
}
elsif (defined $pid) {
sleep 3;
print "($$) i am the child and i finished my work\n";
exit;
}
4 Einträge, 1 Seite |