Leser: 3
7 Einträge, 1 Seite |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
##Variablen für parallele Downloads
my @child_pids = ();
my $max_childs = 2;
for my $i (0..$#ini_data){
$c_childs = @child_pids;
if($c_childs < max_childs)
{
#Erzeugen von Child-Prozessen
$pid = fork();
#Child-Prozess Ablauf
if($pid == 0)
{
WGET BEFEHL
}
else
{
push(@child_pids, $pid);
}
}
}
foreach(@child_pids)
{
waitpid($_, 0);
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
use strict;
use warnings;
use Socket;
use IO::Handle;
my ($kidfh, $dadfh);
socketpair($kidfh, $dadfh, AF_UNIX, SOCK_STREAM, PF_UNSPEC)
or die "socketpair: $!";
$kidfh->autoflush(1);
$dadfh->autoflush(1);
if (my $pid = fork) {
close $dadfh;
print $kidfh "Parent Pid $$ sendet dies\n";
chomp(my $line = <$kidfh>);
print "Parent Pid $$ liest gerade dies: $line\n";
close $kidfh;
waitpid($pid,0);
} else {
close $kidfh;
chomp(my $line = <$dadfh>);
print "Child Pid $$ liest gerade dies: $line\n";
print $dadfh "Child Pid $$ sendet dies\n";
close $dadfh;
exit;
}
7 Einträge, 1 Seite |