Don't abort in |init_once| if |fcntl| returns ENOSYS
Native Client doesn't support fcntl natively and its default
implemention just returns ENOSYS.
Change-Id: Id8615e2f6f0a75a1140f8efd75afde471ccdf466
Reviewed-on: https://boringssl-review.googlesource.com/6721
Reviewed-by: Adam Langley <agl@google.com>
diff --git a/crypto/rand/urandom.c b/crypto/rand/urandom.c
index 1cc5260..5bf5c73 100644
--- a/crypto/rand/urandom.c
+++ b/crypto/rand/urandom.c
@@ -83,11 +83,15 @@
int flags = fcntl(fd, F_GETFD);
if (flags == -1) {
- abort();
- }
- flags |= FD_CLOEXEC;
- if (fcntl(fd, F_SETFD, flags) == -1) {
- abort();
+ /* Native Client doesn't implement |fcntl|. */
+ if (errno != ENOSYS) {
+ abort();
+ }
+ } else {
+ flags |= FD_CLOEXEC;
+ if (fcntl(fd, F_SETFD, flags) == -1) {
+ abort();
+ }
}
urandom_fd = fd;
}