Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Linux
getrandom
failure in interpreted code (#15035)
Whereas the syscall returns the negative of the `Errno` value on failure, the `LibC` function returns -1 and then sets `Errno.value`. Crystal always assumes the former: ```cr err = Errno.new(-read_bytes.to_i) if err.in?(Errno::EINTR, Errno::EAGAIN) ::Fiber.yield else raise RuntimeError.from_os_error("getrandom", err) end ``` https://github.com/crystal-lang/crystal/blob/cde543a762d56324e1d1261154d767c84db1ebc1/src/crystal/system/unix/getrandom.cr#L105-L110 As `EPERM` equals 1 on Linux, _all_ failures are treated like `EPERM` in interpreted code, even though `EPERM` itself is not listed as an error for [`getrandom(2)`](https://man7.org/linux/man-pages/man2/getrandom.2.html), hence the "Operation not permitted". The same can probably happen on other Linux distros if you run out of entropy.
- Loading branch information