Module: wine Branch: master Commit: 3674c77341a0a95c8dc57597ea0a9507acb86b61 URL: http://source.winehq.org/git/wine.git/?a=commit;h=3674c77341a0a95c8dc57597ea...
Author: Ken Thomases ken@codeweavers.com Date: Fri Mar 21 21:32:49 2008 -0500
libwine: Cope with Leopard brokenness w.r.t. setrlimit(RLIMIT_NOFILE).
---
libs/wine/loader.c | 13 ++++++++++++- 1 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/libs/wine/loader.c b/libs/wine/loader.c index 13eb84a..0f05f0c 100644 --- a/libs/wine/loader.c +++ b/libs/wine/loader.c @@ -596,7 +596,18 @@ static void set_max_limit( int limit ) if (!getrlimit( limit, &rlimit )) { rlimit.rlim_cur = rlimit.rlim_max; - setrlimit( limit, &rlimit ); + if (setrlimit( limit, &rlimit ) != 0) + { +#if defined(__APPLE__) && defined(RLIMIT_NOFILE) && defined(OPEN_MAX) + /* On Leopard, setrlimit(RLIMIT_NOFILE, ...) fails on attempts to set + * rlim_cur above OPEN_MAX (even if rlim_max > OPEN_MAX). */ + if (limit == RLIMIT_NOFILE && rlimit.rlim_cur > OPEN_MAX) + { + rlimit.rlim_cur = OPEN_MAX; + setrlimit( limit, &rlimit ); + } +#endif + } } #endif }