Creating Unix processes

Maximum number of files: 1

Create two C++ programs.

Have the first read a single argument that is the string representation of an integer. Loop that many times and display “Process: PID #” where PID is the process identifier and # is 1 — n (n from the first argument). Also have this program return n as its status.

Have the second create a child process and the execute the first program, passing a argument of 5. Have this program wait for the child process exit and report its status.

Your output should look approximately like:

Child PID: 82336
Parent PID: 82335
Process: 82336 1
Process: 82336 2
Process: 82336 3
Process: 82336 4
Process: 82336 5
Process 82336 exited with status: 5

The most relevant manual pages include sleep(3), execl(3), wait(2), perror(3), fork(2), exit(3).

Order from us and get better grades. We are the service you have been looking for.