Song Liu | 81f77fd | 2018-03-14 10:23:22 -0700 | [diff] [blame] | 1 | #include <stdio.h> |
| 2 | #include <unistd.h> |
| 3 | #include <sys/types.h> |
| 4 | #include <sys/stat.h> |
| 5 | #include <fcntl.h> |
| 6 | #include <stdlib.h> |
| 7 | |
| 8 | #define BUF_SIZE 256 |
Song Liu | 13790d1 | 2018-05-07 10:50:49 -0700 | [diff] [blame^] | 9 | |
| 10 | int main(int argc, char *argv[]) |
Song Liu | 81f77fd | 2018-03-14 10:23:22 -0700 | [diff] [blame] | 11 | { |
| 12 | int fd = open("/dev/urandom", O_RDONLY); |
| 13 | int i; |
| 14 | char buf[BUF_SIZE]; |
Song Liu | 13790d1 | 2018-05-07 10:50:49 -0700 | [diff] [blame^] | 15 | int count = 4; |
Song Liu | 81f77fd | 2018-03-14 10:23:22 -0700 | [diff] [blame] | 16 | |
| 17 | if (fd < 0) |
| 18 | return 1; |
Song Liu | 13790d1 | 2018-05-07 10:50:49 -0700 | [diff] [blame^] | 19 | |
| 20 | if (argc == 2) |
| 21 | count = atoi(argv[1]); |
| 22 | |
| 23 | for (i = 0; i < count; ++i) |
Song Liu | 81f77fd | 2018-03-14 10:23:22 -0700 | [diff] [blame] | 24 | read(fd, buf, BUF_SIZE); |
| 25 | |
| 26 | close(fd); |
| 27 | return 0; |
| 28 | } |