perl forking

Thursday, July 15th, 2010 @ 12:45 pm | Notas rápidas, perl

Esquema de como montar forks con perl,

#!/usr/bin/perl

my $pid = fork();
my @childs ;

if ( not defined $pid ) {
    # error no se puede crear el forkç
    print " no es posible crear el fork ";
}

if ( $pid == 0 ) {
    # es un hijo

    # aqui lo que ejecuta el  hijo
    # aqui lo que ejecuta el hijo
   
    exit( 0 ) ;
   
} else {
    # padre , guardmos la lista de hijos para luego, matarlos
   
    push(@childs, $pid);
}

# matar los hijos
    foreach (@childs) {
    waitpid($_, 0);
    }

 

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

 

 

Recently

  • Cómo instalar dropbox en Debian usando los sources , copia y pega
  • Infección en apps de Android
  • virt-manager: ERROR:root:unsupported locale setting
  • sopastrike.com – Vamos a la huelga
  • No me gusta wordpress
  • [Asterisk] Tareas de mantenimiento
  • screengrab queda muerto
  • rails + omniauth + omniauth-twitter
  • Ruby on Rails + Papercliip: cannot load such file — cocaine (LoadError)
  • `autodetect’: Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)
  •