// fork.c // October 28, 2000 // Program to demonstrate the fork call #include #include int main() { int i; char c; pid_t pid; // Create a child process if ((pid = fork()) < 0) { perror("fork"); exit(1); } // end if if (pid == 0) { // This is the code for the child process for (i=0; i < 10; i++) { for (c = 'a'; c <= 'z'; c++) write(1, &c, 1); } // end for i } // end if else { // This is the code for the parent process for (i=0; i < 10; i++) { for (c = 'A'; c <= 'Z'; c++) write(1, &c, 1); } // end for i } // end else // This code is executed for parent and child processes write(1, "\n", 1); exit(0); } // end main