Question: Can you answer the question provided and explain how that answer was provided. Thank you 4. [20 points] Unix I/O and file operations a. [10

Can you answer the question provided and explain how that answer was provided. Thank you

4. [20 points] Unix I/O and file operations

a. [10 points] Suppose that the file tmpdata.txt contains abcdefghijk. If the

following code is executed correctly without generating any errors.

1: int fd;

2: char buf[6] = 12345;

3: fd = open(tmpdata.txt, O_RDONLY);

4: fork( );

5: read(fd, buf, 2);

6: read(fd, buf+2, 2);

7: printf(%d: %s , (long)getpid(), buf);

i). [5pt] Explain if the following two outputs are possible or not? Why/why not? Suppose parent's

pid is 7 while child's pid is 8.

7:a2bc5

8:a2b45

7:a2c45

8:b2de5

ii). [5pt] What could be the outputs if the lines 3 and 4 are exchanged? Write at least 3 possible

outputs. Suppose parent's pid is 7 while child's pid is 8.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!