a. (4 Points) A parent process fopen0s the following file and fgets0s the first
ID: 663089 • Letter: A
Question
a. (4 Points) A parent process fopen0s the following file and fgets0s the first two lines: (1) Mary had a little lamb (2) whose fleece was white a snow (3) and everywhere that Mary went (4) the lamb was sure to go. The parent process then fork0s a child process. That child process also fgets0 two lines. Which s lines does it read? b. A parent process runs a program called one. That process fork0s a child, and that child process successfully exec10s a new program two. After the child finishes two, does it automatically retum to the line after the exec10 in program one? c. A parent process fork0s three child processes to get some work done. All three child processes do finish, and then send SIGUSR1 back to the parent process. Three signals were sent, is the parent process guaranteed to run its SIGUSR1 handler three times? Why or why not? d. Why is it important to have a SIGCHLD handler for most parent processes that fork0s child processes? What will the SIGCHLD handler do?Explanation / Answer
(a)
A child process starts its execution starting from the startement after it was 'forked'. So, in this case, the child process reads lines (3) and (4).
(b)
No.
(c)
Yes, because when kill is called with the pid of the child and SIGUSR1, a signal is sent to every process in the process group of the process that calls kill
(d)
When a child process exits, the operating system sends the SIGCHLD signal.
So, the SIGCHLD handler is important so that after a child process finishes its work and becomes dead, the process cleanup the dead child process, so that any zombie process doesn't remain in the system.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.