반응형
Notice
Recent Posts
Recent Comments
Link
동캄의 코딩도장
FILE I/O [3] 본문
반응형
System calls for fileIO
Duplicating FD - dup(2) /dup2(2)
#include <unistd.h>
int dup (int oldfd);
int dup2 (int oldfd, int newfd);
oldfd (old file descriptor)
- 복사하려는 file descriptor
newfd (new file descriptor)
- 새로운 fd 지정
- dup()의 경우 할당 가능한 fd중 가장 작은 값 할당
Return: oldfd를 복사한 새로운 fd (-1: error)
Manipulating FD - fcntl(2)
#include <unistd.h>
#include <fcntl.h>
int fnctl (int fd, int cmd, /* arg*/ ...);
fd (file descriptor)
- 대상 file descriptor
cmd (command)
- 수행할 명령
arg(argument)
- cmd에 필요한 인자들
Return: cmd에 따라 다름
반응형
'CS > 시스템프로그래밍' 카테고리의 다른 글
DISK I/O [2] (0) | 2022.02.04 |
---|---|
DISK I/O [1] (0) | 2022.02.04 |
FILE I/O [2] (0) | 2022.02.04 |
FILE I/O [1] (0) | 2022.02.04 |
파일 개요& 기본 명령어 (0) | 2022.02.04 |