Ticket #38999: patch_to_100071.diff

File patch_to_100071.diff, 978 bytes (added by ajdudman, 12 years ago)

getrlimit setrlimit patch

  • tracelib.

    old new  
    11/*
    22 * tracelib.c
    3  * $Id: tracelib.c 100071 2012-11-26 20:03:14Z cal@macports.org $
     3 * $Id: tracelib.c 105748 2013-05-04 11:35:30Z cal@macports.org $
    44 *
    55 * Copyright (c) 2007 Eugene Pimenov (GSoC), The MacPorts Project.
    66 * All rights reserved.
     
    430430       
    431431        interp=in;
    432432       
    433         rl.rlim_cur=rl.rlim_max=RLIM_INFINITY;
     433        /* raise the limit of open files to the maximum from the default soft limit
     434         * of 256 */
     435        if (getrlimit(RLIMIT_NOFILE, &rl) == -1)
     436        {
     437                ui_warn("getrlimit failed (%d)", errno);
     438        }
    434439#if defined(__APPLE__) && defined(OPEN_MAX)
    435         if (OPEN_MAX < rl.rlim_cur)
    436                 rl.rlim_cur = OPEN_MAX;
     440        if (rl.rlim_max > OPEN_MAX)
     441                rl.rlim_max = OPEN_MAX;
    437442#endif
    438         if(setrlimit(RLIMIT_NOFILE, &rl)==-1)
     443        rl.rlim_cur = rl.rlim_max;
     444        if (setrlimit(RLIMIT_NOFILE, &rl) == -1)
    439445        {
    440446                ui_warn("setrlimit failed (%d)", errno);
    441447        }