20145235 "Information Security system Design Fundamentals" No. 09 Week Study summary _1 Exercise 10.1
The first problem is usr/include inside no csapp.h and csapp.c downloaded a compressed package from the night, and to understand the pressure tar-xf Code.tar
Then put the inside of the Csapp.h and csapp.c into the usr/include inside.
Then compile and run c101.c. The descriptor return value is 3.
Code Hosting
Impressions and questions
I read the blog that people wrote that the most important thing is to let us understand the descriptor, when opening foo.txt, the descriptor pool of 0, 1, 2 has been used, Then open the Foo.txt, when the kernel returns a descriptor of 1, when the closing foo.txt is closed after the descriptor 3 into the description descriptors, when the Baz.txt is opened, the kernel returns a descriptor of 3, so the program result is 3.
So if you modify the code, do not close the foo.txt, but also the description of foo.txt print out, the results will be what? The results are as follows:
It is obvious that the descriptor is 4. Although the book does not explain the details, through this exercise is thoroughly understand what the descriptor is.
20145235 "Information Security system design basics" No. 09 Week study summary _2