About fork () in Linux:
Parent/child processes created by fork () share the same file table (Linux file descriptor or called ' Open file Descriptor ' )
Which code would the new process execute?
Acutally they share the same code, the different is the return value of fork ();
For a child process, fork () returns zero, but for parent process, the actual
Child process ID which is non-zero.
Reference:
[1] http://stackoverflow.com/questions/11733481/ Can-anyone-explain-a-simple-description-regarding-file-descriptor-after-fork
[2] Http://man7.org/linux/man-pages/man2/fork.2.html
About select () in Linux:
Select () and Pselect () allow a program to monitor multiple file descriptors, waiting until one or more of the file Descrip Tors
Become ' ready ' for some class of I/O operation (e.g., input possible). A file descriptor is considered ready if it is possible
To perform the corresponding I/O operation (e.g., read (2)) without blocking.
My Understanding:
In network programing like Socket,read,write, there is both kinds of API, Readsync () or Readasync (), one would bock if ther E is no data to read,
Another won't block for it would test whether there is data to read. So at the low level, ' select ' Does this kind of thing!
Reference:
[1] Http://linux.die.net/man/2/select
[2] http://stackoverflow.com/questions/14544621/why-is-select-used-in-linux