Question: Problem 2: Analyze this! (15 Pts Consider the following code fragment. For each write statement, indicate where the I/O will be sent (e.g. file name,

Problem 2: Analyze this! (15 Pts Consider the following code fragment. For each write statement, indicate where the I/O will be sent (e.g. file name, stdout, or an error). Also, show the state of the file descriptor (fd) tables for parent and child at points A and B int main () t int fd1, fd2, fd3, fd4; fdl - open ("foo", O RDWR); fd2-open ("bar", O RDWR); fd3 open ("baz", _RDHR); fdA open ("baw", _RDHR); link ("foo", "txt"); dup2 (1, fd3); dup2 (fd2, 1); if (fork () 0) dup2 (fdl, fd4); close (fdl); write (fd3, "", 3); write (1, "bbb", 3) write (fd2, "ccc", 3); write (fdl, "ddd", 3); // point A else [ write (fdl, "fff", 3); dup2 (fdl, fd3); write (fd3, "eee", 3); write (fd4, "g, 3); // point B Problem 2: Analyze this! (15 Pts Consider the following code fragment. For each write statement, indicate where the I/O will be sent (e.g. file name, stdout, or an error). Also, show the state of the file descriptor (fd) tables for parent and child at points A and B int main () t int fd1, fd2, fd3, fd4; fdl - open ("foo", O RDWR); fd2-open ("bar", O RDWR); fd3 open ("baz", _RDHR); fdA open ("baw", _RDHR); link ("foo", "txt"); dup2 (1, fd3); dup2 (fd2, 1); if (fork () 0) dup2 (fdl, fd4); close (fdl); write (fd3, "", 3); write (1, "bbb", 3) write (fd2, "ccc", 3); write (fdl, "ddd", 3); // point A else [ write (fdl, "fff", 3); dup2 (fdl, fd3); write (fd3, "eee", 3); write (fd4, "g, 3); // point B
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
