-
POSIX(UNIX)Platform/File(장치 IO) 2010. 3. 16. 00:21UNIX files, no matter what program created them, can all be accessed as a sequential stream of bytes. When you access a file, you start by opening it by name. The operating system then gives you a number, called a file descriptor, which you use to refer to the file until you are through with it. You can then read and write to the file using its file descriptor. When you are done reading and writing, you then close the file, which then makes the file descriptor useless.STDIN(0)can be redirected from or to a real file, rather than a screen or a keyboardSTDOUT(1)STDERR(2)UNIX-based operating systems treat all input/output systems as files. Network connections are treated as files, your serial port is treated like a file, even your audio devices are treated as files. Communication between processes is usually done through special files called pipes. Some of these files have different methods of opening and creating them than regular files (i.e. - they don’t use the open system call), but they can all be read from and written to using the standard read and write system calls.호환성 라이브러리creat()open()
O_CREAT
O_RDWR
O_TRUNC
O_APPEND
O_EXCL
close()read() // _read()write() // _write()lseek()