ok, i have a father process and a bunch of childs
p) :
for (my $1 ; $i < $n ; $i++) {
my $pipe = new IO:
ipe;
my $child = fork();
if ($child == 0) { #child
my $resp = something();
#child writes the result to the pipe
$pipe->writer();
print $pipe $resp;
exit 0;
} else { #father
#father reads and concatenates all the answers in
#one
$pipe->reader();
while (<$pipe>) {
$res = $res . $_;
}
wait();
}
}
this works fine, the problem is that the childs don't execute concurrently (don't know if i'm expressing right).
the father waits for each child to finish and then another process starts.
Is this a consequence of the pipe, because i think that without the read-write-pipe process the childs execute 'simultaneously'.
thanks...
for (my $1 ; $i < $n ; $i++) {
my $pipe = new IO:
my $child = fork();
if ($child == 0) { #child
my $resp = something();
#child writes the result to the pipe
$pipe->writer();
print $pipe $resp;
exit 0;
} else { #father
#father reads and concatenates all the answers in
#one
$pipe->reader();
while (<$pipe>) {
$res = $res . $_;
}
wait();
}
}
this works fine, the problem is that the childs don't execute concurrently (don't know if i'm expressing right).
the father waits for each child to finish and then another process starts.
Is this a consequence of the pipe, because i think that without the read-write-pipe process the childs execute 'simultaneously'.
thanks...