Advanced Programming for the UNIX environment read the third of the notes-file I/O

Source: Internet
Author: User

Most of the UNIX errors return a negative integer or error code, and 0 is the error code.

1. A file descriptor will be returned when each file is opened

2.unix standard input and output error code file descriptors are replaced with constant Stdin_fileno,stdout_fileno,strerr_fileno (in unistd.h file) in 0 1 2,posix.1 respectively

3.Open function Use (do not remember, write more, more practice, just remember, do not understand the manual, too many parameters)

4.NAME_MAX=14, if the file name exceeds this value, it will be truncated automatically, but the BSD system will error (Enametoolong), not only the file directory problem, the call function can also be problematic
The 5.create (pathname,mode) function creates a new file, returns FD successfully, fails-1, or can be created with open, which creates a file in write-only mode.

The 6.close (int fd) function closes a file, but it closes automatically after the process is finished, but it's a matter of habit to write it, or it will be a big problem (Nonblock).

7.lseek function only modifies offset, no I/O operation

(Each process shares the same v node)

About atomic operations:

To put it bluntly is to point at the end of the offset before each file write operation ... Automatic, before it seems to be manually lseek

(Ps: Atomic operation more than this one)

About DUP and dup2:

Fcntl for modifying file flag values

Advanced Programming for the UNIX environment read the third of the notes-file I/O

Large-Scale Price Reduction
  • 59% Max. and 23% Avg.
  • Price Reduction for Core Products
  • Price Reduction in Multiple Regions
undefined. /
Connect with us on Discord
  • Secure, anonymous group chat without disturbance
  • Stay updated on campaigns, new products, and more
  • Support for all your questions
undefined. /
Free Tier
  • Start free from ECS to Big Data
  • Get Started in 3 Simple Steps
  • Try ECS t5 1C1G
undefined. /

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.