text
stringlengths
0
234
.sh see also
.br fgetgrent (3),
.br getgrent (3),
.br group (5)
.sh colophon
this page is part of release 5.13 of the linux
.i man-pages
project.
a description of the project,
information about reporting bugs,
and the latest version of this page,
can be found at
\%https://www.kernel.org/doc/man\-pages/.
.so man3/gethostbyname.3
.\" copyright (c) 2014, theodore ts'o <[email protected]>
.\" copyright (c) 2014,2015 heinrich schuchardt <[email protected]>
.\" copyright (c) 2015, michael kerrisk <[email protected]>
.\"
.\" %%%license_start(verbatim)
.\" permission is granted to make and distribute verbatim copies of this
.\" manual provided the copyright notice and this permission notice are
.\" preserved on all copies.
.\"
.\" permission is granted to copy and distribute modified versions of
.\" this manual under the conditions for verbatim copying, provided that
.\" the entire resulting derived work is distributed under the terms of
.\" a permission notice identical to this one.
.\"
.\" since the linux kernel and libraries are constantly changing, this
.\" manual page may be incorrect or out-of-date. the author(s) assume.
.\" no responsibility for errors or omissions, or for damages resulting.
.\" from the use of the information contained herein. the author(s) may.
.\" not have taken the same level of care in the production of this.
.\" manual, which is licensed free of charge, as they might when working.
.\" professionally.
.\"
.\" formatted or processed versions of this manual, if unaccompanied by
.\" the source, must acknowledge the copyright and authors of this work.
.\" %%%license_end
.\"
.th getrandom 2 2021-03-22 "linux" "linux programmer's manual"
.sh name
getrandom \- obtain a series of random bytes
.sh synopsis
.nf
.b #include <sys/random.h>
.pp
.bi "ssize_t getrandom(void *"buf ", size_t " buflen ", unsigned int " flags );
.fi
.sh description
the
.br getrandom ()
system call fills the buffer pointed to by
.i buf
with up to
.i buflen
random bytes.
these bytes can be used to seed user-space random number generators
or for cryptographic purposes.
.pp
by default,
.br getrandom ()
draws entropy from the
.i urandom
source (i.e., the same source as the
.ir /dev/urandom
device).
this behavior can be changed via the
.i flags
argument.
.pp
if the
.i urandom
source has been initialized,
reads of up to 256 bytes will always return as many bytes as
requested and will not be interrupted by signals.
no such guarantees apply for larger buffer sizes.
for example, if the call is interrupted by a signal handler,
it may return a partially filled buffer, or fail with the error
.br eintr .
.pp
if the
.i urandom
source has not yet been initialized, then
.br getrandom ()
will block, unless
.b grnd_nonblock
is specified in
.ir flags .
.pp
the
.i flags
argument is a bit mask that can contain zero or more of the following values
ored together:
.tp
.b grnd_random
if this bit is set, then random bytes are drawn from the
.i random