Question: code the following in c - The parent opens an existing file, for example file.txt, using the system call open(). - The parent creates a
code the following in c
- The parent opens an existing file, for example "file.txt", using the system call open(). - The parent creates a child using the system call fork(). - The parent calls the system call wait() to wait for its child process to terminate. - The child uses the file descriptor, returned to the parent by open(), to display on the screen the contents of "file.txt". This task should be done using the read()/write() system calls. - The child sleeps for 5 seconds, prints the message "Child terminating", sleeps for another 5 seconds and, finally calls the exit(20). - The parent, once awake, prints the message "My child has terminated" and print the status value returned by the child. -- The parent terminates
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
