Using system calls, fork(), wait(), open(), close(), read() and write(), write a C program to code a
Question:
Using system calls, fork(), wait(), open(), close(), read() and write(),
write a C program to code a sentence by inversing it, character-wise. In particular, your program should
• Prompts the message "This program codes a sentence",
• Gets in an infinite loop then
1. Promptsthemessage"Enterasentence,e.g.,Goodday,mynameisBigFoot",
2. Reads a whole line from the keyboard,
3. Uses system call fork() to fork then,
– the parent writes the message "I just created a child to perform a task, waiting for my child... and, calls wait() to wait for its child process.
– the child process calls function childFunction()
4. The
– writes the message "I am a child process working for my parent"
child, through childFunction(char *line),
– codes the text stored in line (E.g, the above sentence becomes "tooFgiB si
eman ym , yad doog"),
– in case of an empty line, the child calls exit(55),
Systems analysis and design
ISBN: 978-0136089162
8th Edition
Authors: kenneth e. kendall, julie e. kendall