mirror of
git://sourceware.org/git/glibc.git
synced 2024-11-21 01:12:26 +08:00
hurd: Make getrandom honour GRND_NONBLOCK
* sysdeps/mach/hurd/getrandom.c (__getrandom): Open the random source with O_NONBLOCK when the GRND_NONBLOCK flag is provided. Message-Id: <20191217182929.90989-1-jrtc27@jrtc27.com>
This commit is contained in:
parent
a059f9505b
commit
a45244ce12
@ -27,13 +27,17 @@ ssize_t
|
||||
__getrandom (void *buffer, size_t length, unsigned int flags)
|
||||
{
|
||||
const char *random_source = "/dev/urandom";
|
||||
int open_flags = O_RDONLY | O_CLOEXEC;
|
||||
size_t amount_read;
|
||||
int fd;
|
||||
|
||||
if (flags & GRND_RANDOM)
|
||||
random_source = "/dev/random";
|
||||
|
||||
fd = __open_nocancel(random_source, O_RDONLY | O_CLOEXEC);
|
||||
if (flags & GRND_NONBLOCK)
|
||||
open_flags |= O_NONBLOCK;
|
||||
|
||||
fd = __open_nocancel(random_source, open_flags);
|
||||
if (fd == -1)
|
||||
return -1;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user