Warning:  Undefined array key "view" in /var/www/html/wp-content/uploads/classes/so/1920/lab-examples/index.php on line 2
Warning:  Cannot modify header information - headers already sent by (output started at /var/www/html/wp-content/uploads/classes/so/1920/lab-examples/index.php:2) in /var/www/html/wp-content/uploads/classes/so/1920/lab-examples/index.php on line 47
Warning:  Cannot modify header information - headers already sent by (output started at /var/www/html/wp-content/uploads/classes/so/1920/lab-examples/index.php:2) in /var/www/html/wp-content/uploads/classes/so/1920/lab-examples/index.php on line 48
Warning:  Cannot modify header information - headers already sent by (output started at /var/www/html/wp-content/uploads/classes/so/1920/lab-examples/index.php:2) in /var/www/html/wp-content/uploads/classes/so/1920/lab-examples/index.php on line 49
Warning:  Cannot modify header information - headers already sent by (output started at /var/www/html/wp-content/uploads/classes/so/1920/lab-examples/index.php:2) in /var/www/html/wp-content/uploads/classes/so/1920/lab-examples/index.php on line 50
Warning:  Cannot modify header information - headers already sent by (output started at /var/www/html/wp-content/uploads/classes/so/1920/lab-examples/index.php:2) in /var/www/html/wp-content/uploads/classes/so/1920/lab-examples/index.php on line 51
/**
 *  il processo padre crea una figlio che a sua volta ne crea un altro
 */
#include 
#include 
#include 
int main() {
    pid_t pid;
    printf("PID del processo iniziale: %d\n", getpid());
    /* crea un processo figlio */
    pid = fork();
    /* il codice a seguire viene eseguito da entrambi i processi: padre e figlio
     */
    if (pid == 0) {
        printf("Sono il processo FIGLIO [%d] e mio padre ha PID %d.\n",
               getpid(), getppid());
        pid = fork();
        if (pid == 0) {
            printf("Sono il processo NIPOTE [%d] e mio padre ha PID %d.\n",
                   getpid(), getppid());
            exit(0);
        } else {
            printf("Sono il processo FIGLIO [%d] e termino.\n", getpid());
            exit(0);
        }
    } else {
        printf("Sono il processo PADRE [%d] e mio figlio ha PID %d.\n",
               getpid(), pid);
        printf("Sono sempre il padre e mio padre รจ %d.\n", getppid());
        exit(0);
    }
}