Diego A. Degese wrote, On 15/05/2004 20:41:

esoty de acuerdo con Buanzo....
estaria bueno probar a ver que pasa

En el c�digo que mandaste vos el hijo no muere nunca. El hijo no se muere cuando el padre muere. Cuando init lo toma no lo mata, solo maneja bien el SIGCHLD. O sea... Cuando el hijo termina no queda como zombie, si el hijo ya es un zombie entonces desaparece.



#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>


int main() { pid_t pid;

    printf( "Hola! Soy %d\n", getpid() );

    if ( ( pid = fork() ) == -1 )
    {
        perror( "fork" );
    }
    else if ( pid == 0 )
    {
        int i;

        for ( i = 0; i < 5; i++ )
        {
            printf( "Soy %d y mi padre es %d\n", getpid(), getppid() );
            sleep( 5 );
        }

    }

    sleep( 10 );
    printf( "Soy %d y ahora estoy muriendo!\n", getpid() );

    return 0;
}



[EMAIL PROTECTED]:~/01$ gcc -Wall -o test test.c && ./test
Hola! Soy 28478
Soy 28479 y mi padre es 28478
Soy 28479 y mi padre es 28478
Soy 28478 y ahora estoy muriendo!
[EMAIL PROTECTED]:~/01$ Soy 28479 y mi padre es 1
Soy 28479 y mi padre es 1
Soy 28479 y mi padre es 1
Soy 28479 y ahora estoy muriendo!




-- Lucas Wall <[EMAIL PROTECTED]> Buenos Aires, Argentina http://www.kadath.com.ar PGP 1024D/A5A328DF 826D F289 02F9 D988 2704 54EF 5AFD EBCC A5A3 28DF

Attachment: signature.asc
Description: OpenPGP digital signature

-- 
Para desuscribirte ten�s que visitar la p�gina
https://listas.linux.org.ar/mailman/listinfo/lugar-gral/

Si ten�s alg�n inconveniente o consulta escrib� a mailto:[EMAIL PROTECTED]
Apoya al ASLE enviando tu firma http://www.linux.org.ar/asle

Responder a