Kiss Gabor wrote:
> In article <[email protected]>,
>       Gabor HALASZ <[email protected]> writes:
>>>>> És hogy váltok _egyszerûen_ a két programváltozat közt?
>>> (A véges és a végtelen várakozásra gondolok.)
>> Azt mintha nem irtad volna, hogyan es mikor akarsz valtani :)
> 
> Mert nem is fontos.
> Konkrétan parancssori opciótól függ, de lehetne akár üzemmódot
> váltani minden harmadik felébredés után is.
> "$condition" oszt kész.

Sok a baj veled...;) Forkolas helyett szetszedtem ket reszre az 
egyszeruseg kedveert, lett belole Pepik.pl:

#!/usr/bin/perl

$DONE = 0;
$IPC_KEY = 1234;
$id = semget ($IPC_KEY, 0, 0);
die if !defined ($id);
$semnum = 0;
$semflag = 0;

$SIG{TERM} = sub {
         $DONE++;
};

while (!$DONE) {
         $semop = 0;
         $opstring1 = pack ("s!s!s!", $semnum, $semop, $semflag);
         print "Meee, Hopp!\n";
         $semop = 1;
         $opstring2 = pack ("s!s!s!", $semnum, $semop,  $semflag);
         $opstring = $opstring1 . $opstring2;
         semop ($id,$opstring) || die "$!";
}


Es lett Flanderka.pl:

#!/usr/bin/perl

$timeout = 5;

$counter = 0;
$DONE = 0;
$IPC_KEY = 1234;

$SIG{TERM} = sub {
         $DONE++;
};

$SIG{HUP} = sub {
         $opstring = pack("s!s!s!", $semnum, $semop, $semflag);
         semop($id,$opstring) || die "$!";
};

$id = semget ($IPC_KEY, 0, 0);
die if !defined($id);
$semnum = 0;
$semflag = 0;
$semop = -1;

while (!$DONE) {
         if ($counter == $timeout) {
                 kill HUP, $$;
                $counter = 0;
         } else {
                 $counter++;
                 sleep 1;
         }
}


-- 
Gabor HALASZ <[email protected]>

_________________________________________________
linux lista      -      [email protected]
http://mlf2.linux.rulez.org/mailman/listinfo/linux

válasz