Preview:
int fd = open("/dev/urandom", O_RDONLY);
if (fd == -1)
	goto nodevurandom
if (fstat(fd, &st) == -1 || !S_ISCHR(st.st_mode)) {
	close(fd);
	goto nodevrandom;
}
if (ioctl(fd, RNDGETENTCNT, &cnt) == -1) {
	close(fd);
	goto nodevrandom;
}
ssize_t ret = read(fd, (char *)buf + i, wanted);
if (ret == -1) {
	if (errno == EAGAIN || errno == EINTR)
		continue;
		close(fd);
		goto nodevrandom;
}
close(fd);
if (gotdata(buf, len) == 0) {
	errno = save_errno;
	return 0;
}
nodevrandom:
	errno = EIO;
	return -1;
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter