#include #include #include #include #include /* Maximum number of children */ #define MAX_NO_CLD 10 int main () { int i, ncld, wtime, status; pid_t cpid, mypid, parpid; /* Parent process gets its own ID and its parent's ID */ mypid = getpid(); parpid = getppid(); printf("Parent: PID = %u, PPID = %u\n", mypid, parpid); /* Parent process obtains the number of children from the user */ printf("Parent: Number of children = "); scanf("%d", &ncld); if ((ncld < 0) || (ncld > MAX_NO_CLD)) ncld = 5; printf("\n"); /* Child creation loop */ for (i=0; i