Sono riuscito a passare i valori... thx 
Mi si presenta un altro problema però!
La mia funzione chiamata è quella di gapil in fig 4.3:
codice:
#include <stdlib.h> /* C standard library */
#include <unistd.h> /* unix standard library */
#include <stdio.h> /* standard I/O library */
#include <string.h> /* string functions */
/* Help printing routine */
void usage(void);
main(int argc, char *argv[])
{
/*
* Variables definition
*/
int nchild, i;
pid_t pid1;
int wait_child = 0;
int wait_parent = 0;
int wait_end = 0;
/* handling options */
nchild = atoi(argv[optind]);
printf("Test for forking %d child\n", nchild);
/* loop to fork children */
for (i=0; i<nchild; i++)
{
if ( (pid1 = fork()) < 0)
{
/* on error exit */
printf("Error on %d child creation, %s\n", i+1, strerror(errno));
exit(-1);
}
if (pid1 == 0)
{ /* child */
printf("Child %d successfully executing\n", ++i);
if (wait_child) sleep(wait_child);
printf("Child %d, parent %d, exiting\n", i, getppid());
exit(0);
} else
{ /* parent */
printf("Spawned %d child, pid1 %d \n", i+1, pid1);
if (wait_parent) sleep(wait_parent);
printf("Go to next child \n");
}
}
/* normal exit */
if (wait_end) sleep(wait_end);
return 0;
}
mentre quella chiamante ve l'ho riportata su.
Il problema è questo: come output, passando il valore per es. 2 ho a volte
codice:
Test for forking 2 child
Child 1 successfully executing
Child 1, parent 5953, exiting
Spawned 1 child, pid1 5954
Go to next child
Child 2 successfully executing
Child 2, parent 5953, exiting
Spawned 2 child, pid1 5955
Go to next child
Finito processo maggiore
(che sarebbe quello che vorrei ottenere), altre volte invece non mi aspetta la fine del filgio e dei "nipoti" e mi dà
codice:
Test for forking 2 child
Child 1 successfully executing
Child 1, parent 5957, exiting
Spawned 1 child, pid1 5958
Go to next child
Finito processo maggiore
[andrea@localhost Desktop]$ Child 2 successfully executing
Child 2, parent 5957, exiting
Spawned 2 child, pid1 5959
Go to next child
Sapete come mai?