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

View file

@ -732,7 +732,7 @@ fi
AC_CHECK_FUNCS( wcsdup wcsndup wcslen wcscasecmp wcsncasecmp fwprintf )
AC_CHECK_FUNCS( futimes wcwidth wcswidth wcstok fputwc fgetwc )
AC_CHECK_FUNCS( wcstol wcslcat wcslcpy lrand48_r killpg gettext )
AC_CHECK_FUNCS( dcgettext backtrace backtrace_symbols)
AC_CHECK_FUNCS( dcgettext backtrace backtrace_symbols sysconf )
#
# The Makefile also needs to know if we have gettext, so it knows if

15
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 );
@ -522,18 +524,25 @@ static void launch_process( process_t *p )
sb_format_size( &sz1, sz );
#ifdef ARG_MAX
arg_max = sysconf( _SC_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
}
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 );

View file

@ -1168,3 +1168,20 @@ char ** backtrace_symbols (void *const *buffer, int size)
return 0;
}
#endif
#ifndef HAVE_SYSCONF
long sysconf(int name)
{
if( name == _SC_ARG_MAX )
{
#ifdef ARG_MAX
return ARG_MAX;
#endif
}
return -1;
}
#endif

View file

@ -435,4 +435,11 @@ int getopt_long(int argc,
#endif
#ifndef HAVE_SYSCONF
#define _SC_ARG_MAX 1
long sysconf(int name);
#endif
#endif