Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

do this code in c Question 5 Using Unix system calls, fork(), wait(), read() and write(), write a C program for integer- basic Arithmetics (+,,,/).

do this code in c

image text in transcribed

Question 5 Using Unix system calls, fork(), wait(), read() and write(), write a C program for integer- basic Arithmetics (+,,,/). Your program should follow the sequential steps, given below. - Prompts the message "This program makes simple arithmetics", - Gets in an infinite loop then 1. Writes the message "Enter an arithmetic statement, e.g., 34+ 132>n 2. Reads the whole input line, 3. Forks and - the parent writes the message "Created a child to make your operation, waiting" then calls wait() to wait for its child. - the child process calls the function childFunction(char *) and never returns. 4. The child, through childFunction(char *line), - writes the message "I am a child working for my parent" - uses sscanf() to convert the input line into an integer, a character and an integer, respectively. - in case of wrong statement, the child calls exit(50) - in case of division by zero, the child calls exit(100) - in case of a wrong op the child calls exit(200) - otherwise, it performs the appropriate arithmetic operation, - uses sprint() to create an output buffer consisting of n1 op n2= result, - writes the output buffer to the screen - calls exit (0) 5. Once the child terminates, the parent checks the returned status value using bit-manipulation macros discussed in class and if it is 50,100 or 200 , writes "Wrong statement", "Division by zero" or "Wrong operator", respectively

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing

Authors: David M. Kroenke, David Auer

11th Edition

B003Y7CIBU, 978-0132302678

More Books

Students also viewed these Databases questions