[Viana-pm] selective KILLing...
Joao Miguel Ferreira
aventuras.de.joao.sem.medo at gmail.com
Fri Oct 26 09:14:07 PDT 2007
Olá a todos,
(oi meui tecladoi está a escrever 'i's quiandoii carregoi em 'o' e 'u's,
descuilpem.....)
p.f. reparem neste código:
--------------------------------------
sub something_timed_out {die "GOT TIRED OF WAITING";};
$SIG{ALRM} = \&something_timed_out;
--------------------------------------
$rv='Ok';
eval
{
$child=fork;
if (defined($child)) {
if ($child) {
alarm(10);
wait;
alarm(0);
$rv='child didnt take more than 10 secs';
} else {
do_some_very_slow_stuff;
exit 1;
};
} else {
$rv="Cannot cannot fork";
};
};
if ($@)
{
if ($@ =~ /GOT TIRED OF WAITING/)
{
system("kill -TERM $child");
$rv="child did take long so I TERMed it";
};
$rv="error !?!";
};
return $rv;
--------------------------------------
proiblema: isto é para coiirrer em root !!!!!!!!!
tenhoi receio de, noi kill, em vez de matar o meu child, matar uim
oiuitroi quialquier que entretantoi tenha apanhadoi aquiele PID.
Ou o SO coinsegue gerir os PIDs poir foirma a não atribuiir este antes
doii pai terminar ????
há coimentários ?
thx++;
return 0;
};
Joao Ferreira
More information about the Viana-pm
mailing list