#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
//----------------------------------------------------------
int
main ( void )
{
pid_t pid;
//
printf ( "Io sono il genitore e il mio numero PID " "รจ %i.\n " ,
( int ) getpid ( ) ) ;
pid = fork ( ) ;
if ( pid == 0 )
{
printf ( "Io sono il figlio della biforcazione " "e il mio genitore ha il numero "
"PID %i.\n " , ( int ) getppid ( ) ) ;
}
else
{
printf ( "Ho avviato una biforcazione di me " "stesso, la quale ha ottenuto il "
"numero PID %i.\n " , pid) ;
}
return ( 0 ) ;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDx1bmlzdGQuaD4KI2luY2x1ZGUgPHN0ZGxpYi5oPgovLy0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0KaW50Cm1haW4gKHZvaWQpCnsKICAgIHBpZF90ICBwaWQ7CiAgICAvLwogICAgcHJpbnRmICgiSW8gc29ubyBpbCBnZW5pdG9yZSBlIGlsIG1pbyBudW1lcm8gUElEICIKICAgICAgICAgICAgIsOoICVpLlxuIiwKICAgICAgICAgICAgKGludCkgZ2V0cGlkICgpKTsKICAgIHBpZCA9IGZvcmsgKCk7CiAgICBpZiAocGlkID09IDApCiAgICAgIHsKICAgICAgICBwcmludGYgKCJJbyBzb25vIGlsIGZpZ2xpbyBkZWxsYSBiaWZvcmNhemlvbmUgIgogICAgICAgICAgICAgICAgImUgaWwgbWlvIGdlbml0b3JlIGhhIGlsIG51bWVybyAiCiAgICAgICAgICAgICAgICAiUElEICVpLlxuIiwgKGludCkgZ2V0cHBpZCAoKSk7CiAgICAgICAgZXhpdCAoMCk7CiAgICAgIH0KICAgIGVsc2UKICAgICAgewogICAgICAgIHByaW50ZiAoIkhvIGF2dmlhdG8gdW5hIGJpZm9yY2F6aW9uZSBkaSBtZSAiCiAgICAgICAgICAgICAgICAic3Rlc3NvLCBsYSBxdWFsZSBoYSBvdHRlbnV0byBpbCAiCiAgICAgICAgICAgICAgICAibnVtZXJvIFBJRCAlaS5cbiIsIHBpZCk7CiAgICAgIH0KICAgIHJldHVybiAoMCk7Cn0=