Make the maximum execve size test use sysconf. Create a fallback if sysconf is unavailable.

darcs-hash:20071015113936-75c98-078e9f8727e91d41fabc80827bf97c8e04dd97ba.gz
This commit is contained in:
liljencrantz
2007-10-15 21:39:36 +10:00
parent dd02e96712
commit 36e08dc49e
4 changed files with 45 additions and 12 deletions

31
exec.c
View File

@@ -507,6 +507,8 @@ static void launch_process( process_t *p )
string_buffer_t sz1;
string_buffer_t sz2;
long arg_max = -1;
sb_init( &sz1 );
sb_init( &sz2 );
@@ -521,19 +523,26 @@ static void launch_process( process_t *p )
}
sb_format_size( &sz1, sz );
arg_max = sysconf( _SC_ARG_MAX );
#ifdef ARG_MAX
sb_format_size( &sz2, ARG_MAX );
if( arg_max > 0 )
{
sb_format_size( &sz2, ARG_MAX );
debug( 0,
L"The total size of the argument and environment lists (%ls) exceeds the system limit of %ls.",
(wchar_t *)sz1.buff,
(wchar_t *)sz2.buff);
}
else
{
debug( 0,
L"The total size of the argument and environment lists (%ls) exceeds the system limit.",
(wchar_t *)sz1.buff);
}
debug( 0,
L"The total size of the argument and environment lists (%ls) exceeds the system limit of %ls.",
(wchar_t *)sz1.buff,
(wchar_t *)sz2.buff);
#else
debug( 0,
L"The total size of the argument and environment lists (%ls) exceeds the system limit.",
(wchar_t *)sz1.buff);
#endif
debug( 0,
L"Please try running the command again with fewer arguments.");
sb_destroy( &sz1 );