1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-03-12 01:42:37 -07:00

Initialize command-line-max-length with sysconf(3)

* lisp/subr.el (command-line-max-length): Move from here ...
* src/callproc.c (syms_of_callproc): <Vcommand_line_max_length>:
... to here.  Initialize by calling sysconf(3) if possible.
This commit is contained in:
Sean Whitton 2026-02-28 10:23:11 +00:00
parent 58b195e5a3
commit 3b223db8a7
2 changed files with 14 additions and 14 deletions

View file

@ -5089,20 +5089,6 @@ newlines."
shell-file-name delete buffer nil
shell-command-switch command))
(defvar command-line-max-length
;; Currently we use the same value everywhere. If we actually use
;; larger values on some systems at some point, then we need to make
;; sure we handle whether the command will be run remotely via TRAMP.
;; FIXME: This value is very small, it might easily all be used up by
;; `process-environment'. We really want a larger value on POSIX.
4096
"Maximum length of a command and its arguments on this system.
This is measured in characters.
Used by `multiple-command-partition-arguments'. Other code calls that
function for cases in which it's known to be safe to run the command
multiple times on subsequent partitions of the list of arguments.
(In a shell script, you might use the `xargs' utility.)")
(defun multiple-command-partition-arguments (command arguments &optional shellp)
"Partition ARGUMENTS of COMMAND to avoid command line length limits.
This function is for running commands on each element of ARGUMENTS where

View file

@ -2237,6 +2237,20 @@ the system. */);
Vrcs2log_program_name = build_string ("librcs2log.so");
#endif /* !HAVE_ANDROID || ANDROID_STUBIFY */
DEFVAR_LISP ("command-line-max-length", Vcommand_line_max_length,
doc: /* Maximum length of a command and its arguments on this system.
This is measured in characters.
Used by `multiple-command-partition-arguments'. Other code calls that
function for cases in which it's known to be safe to run the command
multiple times on subsequent partitions of the list of arguments.
(In a shell script, you might use the `xargs' utility.) */);
#if defined _SC_ARG_MAX
/* Divide it by 4 as a crude way to go bytes->characters. */
Vcommand_line_max_length = make_fixnum (sysconf (_SC_ARG_MAX) / 4);
#else /* defined _SC_ARG_MAX */
Vcommand_line_max_length = make_fixnum (4096);
#endif /* defined _SC_ARG_MAX */
defsubr (&Scall_process);
defsubr (&Sgetenv_internal);
defsubr (&Scall_process_region);