Operating System - HP-UX
1834150 Members
2370 Online
110064 Solutions
New Discussion

How to set ARG_MAX variable?

 
Aseem Mithal
New Member

How to set ARG_MAX variable?

We are using HP Unix OS and want to know that how can we set the configurable system variable ARG_MAX(Maximum total length for exec in bytes,including environmental data).
4 REPLIES 4
harry d brown jr
Honored Contributor

Re: How to set ARG_MAX variable?


/usr/include/limits.h

live free or die
harry
Live Free or Die
Steve Steel
Honored Contributor

Re: How to set ARG_MAX variable?

Hi

Per the sysconf(2) manpage, `getconf ARG_MAX` is documented as:


ARG_MAX _SC_ARG_MAX Maximum total length of the arguments for
exec() in bytes, including environment
data (see exec(2))


On 10.20 you need patch 16751 or equivalent and
its dependencies


When this patch is installed the default environment size is 20478 bytes. To enable the system to use the larger environment size of 2048000 bytes, the following steps must
be followed.

1. A new tunable called `large_ncargs_enabled' must be defined in the sytem file in the following manner large_ncargs_enabled 1

2. A new kernel must be built (using this system file) and the system rebooted.

To return to the default environment size, the new tunable needs to be either removed from the system file, or its value set to zero. A new kernel should then be built (using the modified system file) and the machine rebooted.




On 11 the parameter is bigger by default.

Steve Steel
If you want truly to understand something, try to change it. (Kurt Lewin)
Bill Hassell
Honored Contributor

Re: How to set ARG_MAX variable?

Setting the ARG_MAX to a different value will not help. Normally, this is required because someone has thousands of filenames in a single directory and you want refer to all of them by name, as in:

echo *

The shell will complain about line too long because the shell does not have enough space to hold all of these names on one line. The ARG_MAX sets this value but unless the shell allocates it's command line buffers dynamically, it woun't make a difference. No matter how large a new patch will make the ATG_MAX value, there are cases where it won't be long enough.

Instead, look at the command xargs to provide a filter between enormously long lines and commands that have limited capability.


Bill Hassell, sysadmin
harry d brown jr
Honored Contributor

Re: How to set ARG_MAX variable?

Bill,

Damn good points!!!

xargs to the rescue?

live free or die
harry
Live Free or Die