/*
Programmazione II - Esempio di codice
Example code: fork-exec demonstration. (20000809 prelz@mi.infn.it)
*/
#include
#include
int
main(int argc, char *argv[])
{
pid_t retpid;
retpid = fork();
if (retpid == 0)
{
/* Here we are in the subprocess */
/* We execute cat /proc/meminfo */
execlp("cat","cat","/proc/meminfo",NULL);
/* We never reach here....*/
}
printf ("Created subprocess PID is %d.\n",retpid);
exit(0);
}