Movatterモバイル変換


[0]ホーム

URL:


man7.org > Linux >man-pages

Linux/UNIX system programming training


getentropy(3) — Linux manual page

NAME |LIBRARY |SYNOPSIS |DESCRIPTION |RETURN VALUE |ERRORS |STANDARDS |HISTORY |NOTES |SEE ALSO |COLOPHON

getentropy(3)            Library Functions Manualgetentropy(3)

NAME        top

       getentropy - fill a buffer with random bytes

LIBRARY        top

       Standard C library (libc,-lc)

SYNOPSIS        top

#include <unistd.h>int getentropy(size_t length;voidbuffer[length], size_tlength);   Feature Test Macro Requirements for glibc (seefeature_test_macros(7)):getentropy():           _DEFAULT_SOURCE

DESCRIPTION        top

       Thegetentropy() function writeslength bytes of high-quality       random data to the buffer starting at the location pointed to bybuffer.  The maximum permitted value for thelength argument is       256.       A successful call togetentropy() always provides the requested       number of bytes of entropy.

RETURN VALUE        top

       On success, this function returns zero.  On error, -1 is returned,       anderrno is set to indicate the error.

ERRORS        top

EFAULTPart or all of the buffer specified bybuffer andlength is              not in valid addressable memory.EIOlength is greater than 256.EIOAn unspecified error occurred while trying to overwritebuffer with random data.ENOSYSThis kernel version does not implement thegetrandom(2)              system call required to implement this function.

STANDARDS        top

       None.

HISTORY        top

       glibc 2.25.  OpenBSD.

NOTES        top

       Thegetentropy() function is implemented usinggetrandom(2).       Whereas the glibc wrapper makesgetrandom(2) a cancelation point,getentropy() is not a cancelation point.getentropy() is also declared in<sys/random.h>.  (No feature test       macro need be defined to obtain the declaration from that header       file.)       A call togetentropy() may block if the system has just booted and       the kernel has not yet collected enough randomness to initialize       the entropy pool.  In this case,getentropy() will keep blocking       even if a signal is handled, and will return only once the entropy       pool has been initialized.

SEE ALSO        top

getrandom(2),urandom(4),random(7)

COLOPHON        top

       This page is part of theman-pages (Linux kernel and C library       user-space interface documentation) project.  Information about       the project can be found at        ⟨https://www.kernel.org/doc/man-pages/⟩.  If you have a bug report       for this manual page, see       ⟨https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/tree/CONTRIBUTING⟩.       This page was obtained from the tarball man-pages-6.16.tar.gz       fetched from       ⟨https://mirrors.edge.kernel.org/pub/linux/docs/man-pages/⟩ on       2026-01-16.  If you discover any rendering problems in this HTML       version of the page, or you believe there is a better or more up-       to-date source for the page, or you have corrections or       improvements to the information in this COLOPHON (which isnot       part of the original manual page), send a mail to       man-pages@man7.orgLinux man-pages 6.16            2025-06-28getentropy(3)

Pages that refer to this page:getrandom(2)random(7)



HTML rendering created 2026-01-16 byMichael Kerrisk, author ofThe Linux Programming Interface.

For details of in-depthLinux/UNIX system programming training courses that I teach, lookhere.

Hosting byjambit GmbH.

Cover of TLPI


[8]ページ先頭

©2009-2026 Movatter.jp