#include #include #include #include int main(){ pid_t pid; /* fork a child process */ pid = fork(); if (pid < 0){ // error cerr << "Fork failed\n"; exit(-1); } else if (pid == 0){ // child process // cout << "Child process\n"; execlp("/bin/ls","ls",NULL); cout << "Child process\n"; } else{ // parent process // parent will wait for child to complete wait(NULL); // cout << "Child Complete\n"; execlp("/bin/ls","ls",NULL); cout << "done!\n"; exit(0); } }