/[global]/global/libutil/env.c
ViewVC logotype

Diff of /global/libutil/env.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.8 by h-iwamoto, Wed Jun 22 11:43:08 2005 UTC revision 1.9 by shigio, Sat Jul 30 03:15:02 2005 UTC
# Line 1  Line 1 
1  /*  /*
2   * Copyright (c) 2003 Tama Communications Corporation   * Copyright (c) 2003, 2005 Tama Communications Corporation
3   *   *
4   * This file is part of GNU GLOBAL.   * This file is part of GNU GLOBAL.
5   *   *
# Line 29  Line 29 
29  #else  #else
30  #include <strings.h>  #include <strings.h>
31  #endif  #endif
32    #ifdef HAVE_LIMITS_H
33    #include <limits.h>
34    #endif
35  #ifdef HAVE_HOME_ETC_H  #ifdef HAVE_HOME_ETC_H
36  #include <home_etc.h>  #include <home_etc.h>
37  #endif  #endif
# Line 39  Line 42 
42    
43  extern char **environ;  extern char **environ;
44    
45    #if !defined(ARG_MAX) && defined(_SC_ARG_MAX)
46    #define ARG_MAX         sysconf(_SC_ARG_MAX)
47    #endif
48    
49  /*  /*
50   * set_env: put environment variable.   * set_env: put environment variable.
51   *   *
# Line 90  env_size(void) Line 97  env_size(void)
97          return size;          return size;
98  }  }
99    
100    /*
101     * exec_line_limit: upper limit of bytes of exec line.
102     *
103     *      r)      0: unknown or cannot afford long line.
104     *              > 0: upper limit of exec line
105     */
106    int
107    exec_line_limit()
108    {
109            int limit = 0;
110    
111    #ifdef ARG_MAX
112            /*
113             * POSIX.2 limits the exec(2) line length to ARG_MAX - 2048.
114             */
115            limit = ARG_MAX - 2048;
116            /*
117             * The reason is unknown but the xargs(1) in GNU findutils
118             * use this limit.
119             */
120            if (limit > 20 * 1024)
121                    limit = 20 * 1024;
122            limit -= env_size();
123            if (limit < 0)
124                    limit = 0;
125    #endif
126            return limit;
127    }

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26