#include #include #include #include /* declare a global variable */ static int check = 0; /* function to be executed by created process */ void* go_smith(void* arg) { pid_t *psmith = (pid_t*) arg; check++; printf("I am Agent Smith %u @%p (%d)\n",(unsigned)*psmith,&check,check); exit(0); } int main(int argc, char *argv[]) { pid_t smith; check++; if(!fork()) { smith = getpid(); go_smith(&smith); } waitpid(smith,0x0,0); /* wait for create process to finish */ printf("I am Agent Smith 0 @%p (%d)\n",&check,check); return 0; }