Fork () in Linux

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.