-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathreader.c
40 lines (36 loc) · 1.12 KB
/
reader.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include<stdio.h>
#include<stdlib.h>
#include<sys/types.h>
#include<sys/uio.h>
#include<fcntl.h>
#include<unistd.h>
int main(void) {
int fd;
int bytes_read;
char buf[51200];
fd = open("./delme.txt", O_RDONLY);
printf("fd = %d\n", fd);
bytes_read = read(fd, buf, sizeof(buf));
printf("%d bytes read: %s\n", bytes_read, buf);
printf("________\n");
// 1 sec = 1000000
//usleep(500000);
sleep(5);
bytes_read = read(fd, buf, sizeof(buf));
printf("%d bytes read: %s\n", bytes_read, buf);
bytes_read = read(fd, buf, sizeof(buf));
printf("%d bytes read: %s\n", bytes_read, buf);
printf("________\n");
bytes_read = read(fd, buf, sizeof(buf));
printf("%d bytes read: %s\n", bytes_read, buf);
bytes_read = read(fd, buf, sizeof(buf));
printf("%d bytes read: %s\n", bytes_read, buf);
printf("________\n");
bytes_read = read(fd, buf, sizeof(buf));
printf("%d bytes read: %s\n", bytes_read, buf);
bytes_read = read(fd, buf, sizeof(buf));
printf("%d bytes read: %s\n", bytes_read, buf);
printf("________\n");
bytes_read = read(fd, buf, sizeof(buf));
printf("%d bytes read: %s\n", bytes_read, buf);
}