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 |
* |
* |
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 |
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 |
* |
* |
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 |
|
} |