#!/bin/perl -w use strict; pipe(READER,WRITER); # used for communication between child and parent my $zahl = 0; # number of currently running children my $zeile; # row my $pid; # process ID if (open FILE, "< /sls_backup/mdjanan/sleep.txt") { while($zeile = ) { if ($zahl < 5) { $zahl++; # increase number of children $pid = fork(); # a new child is born. yay :) } # if ($zahl < 5) if($pid != 0) { # parent-process print WRITER $zeile; # send child a command $| = 1; # flush pipe if($zahl == 5) # four children are running. wait till one of them finishes. { while(! wait()) # *waiting* { } # while(! wait()) $zahl--; # decrease number of children } # if($zahl == 5) } # if($pid != 0) else { # child-process # wait for command from parent while (my $line = ) { exec($line); # execute command } # while (my $line = ) } # else } # while($zeile = ) } # if (open FILE, "< /sls_backup/mdjanan/sleep.txt") else { print "\nCan't open file /sls_backup/mdjanan/sleep.txt\n"; } # else exit 0;