#include #include int main(int argc, char **argv) { printf("--beginning of program\n"); int counter = 0; pid_t pid = fork(); if (pid == 0) { // child process counter++; printf("child process: counter=%d\n", counter); } else if (pid > 0) { // parent process counter++; printf("parent process: counter=%d\n", counter); wait(pid); }else{ printf("fork() failed!\n"); } printf("--[PID%d] end of program. count =%d--\n", getpid(), counter); return 0; }