+ lvalue = rl.rlim_cur;
+#else
+ /*
+ * In 32 bit world (watches), sysconf falls back to the
+ * old behavior: use (int) OPEN_MAX as max limit. Ideally
+ * we would use maxfilesperproc as max limit, which is a
+ * system value adjusted by the kernel based on available
+ * RAM size. This value defaults to OPEN_MAX for systems
+ * with less than 8G of RAM. So we use OPEN_MAX (defined
+ * in sys/syslimits.h) as max limit here in case
+ * applications with strict sandbox rules prevent libc
+ * from reading maxfilesperproc via sysctl.
+ */
+ if (rl.rlim_cur > OPEN_MAX)
+ lvalue = OPEN_MAX;
+ else
+ lvalue = (long)rl.rlim_cur;
+#endif
+ return lvalue;