2018-03-15 00:23:22 +07:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#define BUF_SIZE 256
|
2018-05-08 00:50:49 +07:00
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
2018-03-15 00:23:22 +07:00
|
|
|
{
|
|
|
|
int fd = open("/dev/urandom", O_RDONLY);
|
|
|
|
int i;
|
|
|
|
char buf[BUF_SIZE];
|
2018-05-08 00:50:49 +07:00
|
|
|
int count = 4;
|
2018-03-15 00:23:22 +07:00
|
|
|
|
|
|
|
if (fd < 0)
|
|
|
|
return 1;
|
2018-05-08 00:50:49 +07:00
|
|
|
|
|
|
|
if (argc == 2)
|
|
|
|
count = atoi(argv[1]);
|
|
|
|
|
|
|
|
for (i = 0; i < count; ++i)
|
2018-03-15 00:23:22 +07:00
|
|
|
read(fd, buf, BUF_SIZE);
|
|
|
|
|
|
|
|
close(fd);
|
|
|
|
return 0;
|
|
|
|
}
|