It is created each time the server accepts a

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ed is guaranteed to receive the smallest available descriptor in the pool. When a process terminates for any reason, the kernel closes all open files, and frees their memory resources. By convention, each process created by a Unix shell begins life with three open files: standard input (descriptor 0), standard output (descriptor 1), and standard error (descriptor 2). The system header file unistd.h defines the following constants, #define STDIN_FILENO 0 #define STDOUT_FILENO 1 #define STDERR_FILENO 2 which for clarity can be used instead of explicit descriptor values. 12.4.1 The read and write Functions Applications perform input and output by calling the read and write functions, respectively. #include <unistd.h> ssize t read(int fd, void *buf, size t count); returns: number of bytes read if OK, 0 on EOF, -1 on error ssize t write(int fd, const void *buf, size t count); returns: number of bytes written if OK, -1 on error The read function copies at most count bytes from the current file position of descri...
View Full Document

This note was uploaded on 09/02/2010 for the course ELECTRICAL 360 taught by Professor Schultz during the Spring '10 term at BYU.

Ask a homework question - tutors are online