Question: Requirements : written in C in bash shell For this project I want you to write, in C, 2 programs to pass information from one

Requirements: written in C in bash shell

For this project I want you to write, in C, 2 programs to pass information from one to the other.

First write a C program main.c to create a child process; then store pid, ppid (of the parent and child process) and current time into a file called log.txt. Parent process waits for the child to terminate, when that happens write the patent and childs status code to the file (use WEXITSTATUS()). Name the executable file math.

Create another C program square.c to find square of a number that is passed from command line argument when executing math and store the answer into log.txt as well. Name the executable file square. This should be done by the child process and use of exec() family call .

Make sure to create just one child process. Id like to see the use of perror()and git. I also want a Makefile with a target all that makes both of the executables (math and square.) I do not want you to turn in any .o file or the executables.

Program runs as below:

$ math 9

$ cat log.txt

9 squared is: 81

Child pid: 6956 ppid: 6955 date: Sun Jul 29 17:35:12 2018

Child Exit code: 37

Parent pid: 6955 ppid: 12400 date: Sun Jul 29 17:35:12 2018

Parent Exit code: 117

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!