Fix OSX 10.6 / iOS 4.2

This commit is contained in:
Un1q32 2024-04-24 00:29:27 -04:00
parent 5790d25397
commit 9a9a95f99b

View File

@ -227,7 +227,12 @@ int LJ_FASTCALL lj_prng_seed_secure(PRNGState *rs)
** or the OS ran out of file descriptors.
*/
{
#ifdef O_CLOEXEC
int fd = open("/dev/urandom", O_RDONLY|O_CLOEXEC);
#else
int fd = open("/dev/urandom", O_RDONLY);
fcntl(fd, F_SETFD, FD_CLOEXEC);
#endif
if (fd != -1) {
ssize_t n = read(fd, rs->u, sizeof(rs->u));
(void)close(fd);