Figure8.2 illustrates how ?les areshared between a parent process and its child process. Write a program to validate that all open ?le descriptors in the parent and child point to the same ?les, and that the ?le status ?ags and offsets areshared

What will be an ideal response?

The solution is shown in Figure23. Top rove that two ?le descriptors refer to the same ?le, we use fstat(2) and print the st_dev and st_ino ?elds so that we can visually comparethem in the command’s output. Each ?le system has a different st_dev value, and every ?le has a different inode number within a given ?le system. Thus, the combination of the two values uniquely identi?es a ?le on a given computer system

Note that ?le offsets have no meaning for terminal devices and network devices, and some systems will fail calls to lseek(2) on these types of ?les. Therefore, we print 0 for the standardinput, standardoutput, and standarderror if they are associated with a device (the st_rdev ?eld of the stat structurewith be nonzerofor a device special ?le). To validate the offsets areshared, we open a regular ?le (/etc/passwd)and change the ?le offset in the parent. Weuse the process synchronization primitives introduced in Section 8.9 to control when the parent and child processes run (although as we’ll see in Exercise 10.14, this is just good luck, because the check_openfiles function takes enough time to avoid races). Wecan see that after the pare

Computer Science & Information Technology

You might also like to view...

Create a decision table that describes the discount rules.

What will be an ideal response?

Computer Science & Information Technology

The Safari browser’s viewport in portrait view on the iPad is:

a. 320 pixels wide b. 768 pixels wide c. 480 pixels wide d. 980 pixels wide

Computer Science & Information Technology