[Viana-pm] selective KILLing...

Joao Miguel Ferreira aventuras.de.joao.sem.medo at gmail.com
Fri Oct 26 10:31:14 PDT 2007


On Fri, 2007-10-26 at 18:18 +0100, Luis Azevedo wrote:
> Boas João,
> 
> Antes de mais vê se reparas mas é esse teclado :PPPPP
> 
> 1) Em linux, o PID é um contador de 16 bit sempre incremental, i.e., quando 
> chega o limite, recomeça a contagem sem colidir com PID's atribuídos nesse 
> mesmo instante. Acho muito improvável que aconteçam colisões, mas podes fazer 
> um script para criar processos e "dar a volta" ao contador até chegar o PID o 
> teu child. Depois verificas se o kill é feito ao teu $child.
> 
> 2) Devias usar a função "kill" em vez do system("kill...), see: perldoc -f 
> kill
>     If SIGNAL is zero, no signal is sent to the process.  This is a useful way 
> to check that a child process is alive and hasn’t changed its UID.  
>    Podes sempre verificar se o filho não morreu com o kill e a seguir matar! 
> Killing spree :)

coimoi sempre ois teuis esclarecimentois sãoi.... buill's eye. estoiui
esclarecidoi.

vou testar. thx

> 
> Hope it helps, abraço.
> 
> Luís Azevedo
> 
> P.S: Ainda me estou a rir do que te aconteceu ao teclado :PP

loioioioioioioioioioil

rir é sempre oi melhjoir remédioi. :::::DDDDDD

>  Podias usar um 
> USB, não? :P
> 

nãoii acreditoi em soiluiçõies proivisóirias... coimigoi, oiui vai oiui
racha !!!!!



fica bem. espero que as coisas estejam a melhorar tanto quanto poissivel
aí em tua casa. take it easy.

Cheers.
jmf


> 
> On Friday 26 October 2007, Joao Miguel Ferreira wrote:
> >  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
> >
> >
> >
> >  _______________________________________________
> >  Viana-pm mailing list
> >  Viana-pm at pm.org
> >  http://mail.pm.org/mailman/listinfo/viana-pm
> 
> 



More information about the Viana-pm mailing list