/********************************************************** // Author: Abdirahim Abdi // Assignment: Lab 2 // Class: CSE 660 - Operating Systems // Description: Operating System Commands // File DD.cpp **********************************************************/ #include #include #include #include #include #include #include #include using namespace std; /*************************************/ int main(int argc, char *argv[]) { cout << "Process ID DD" << ": " << getpid() << "(CODE DD)" << " - Created process id(CODE CC) and waiting for 4 seconds.\n\n"; int process_c3 = 0; process_c3 = fork(); if (process_c3 == 0) { execv("CC", argv); } cout << "Process ID DD" << ": " << getpid() << " - Created new process(ps) and waiting to terminate.\n\n"; int new_process = 0; new_process = fork(); if (new_process == 0) { execlp("/bin/ps", "-u abdiab"); exit(3); } sleep(4); kill(process_c3, SIGKILL); cout << "Process ID DD " << ": " << getpid() << " - terminating processs id " << process_c3 << ".\n\n"; exit(0); }