aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean Whitton2026-02-28 10:23:11 +0000
committerSean Whitton2026-02-28 10:23:11 +0000
commit3b223db8a7fc97e51dadd62da99650201a83e39e (patch)
treee91c244b28eb23730ed41ca3d66815e6d241ffb9
parent58b195e5a3214d7f54d7f4481c3e3606bf4c7864 (diff)
downloademacs-3b223db8a7fc97e51dadd62da99650201a83e39e.tar.gz
emacs-3b223db8a7fc97e51dadd62da99650201a83e39e.zip
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.
-rw-r--r--lisp/subr.el14
-rw-r--r--src/callproc.c14
2 files changed, 14 insertions, 14 deletions
diff --git a/lisp/subr.el b/lisp/subr.el
index b9fbd739a5a..4cae2845d96 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -5089,20 +5089,6 @@ newlines."
5089 shell-file-name delete buffer nil 5089 shell-file-name delete buffer nil
5090 shell-command-switch command)) 5090 shell-command-switch command))
5091 5091
5092(defvar command-line-max-length
5093 ;; Currently we use the same value everywhere. If we actually use
5094 ;; larger values on some systems at some point, then we need to make
5095 ;; sure we handle whether the command will be run remotely via TRAMP.
5096 ;; FIXME: This value is very small, it might easily all be used up by
5097 ;; `process-environment'. We really want a larger value on POSIX.
5098 4096
5099 "Maximum length of a command and its arguments on this system.
5100This is measured in characters.
5101Used by `multiple-command-partition-arguments'. Other code calls that
5102function for cases in which it's known to be safe to run the command
5103multiple times on subsequent partitions of the list of arguments.
5104(In a shell script, you might use the `xargs' utility.)")
5105
5106(defun multiple-command-partition-arguments (command arguments &optional shellp) 5092(defun multiple-command-partition-arguments (command arguments &optional shellp)
5107 "Partition ARGUMENTS of COMMAND to avoid command line length limits. 5093 "Partition ARGUMENTS of COMMAND to avoid command line length limits.
5108This function is for running commands on each element of ARGUMENTS where 5094This function is for running commands on each element of ARGUMENTS where
diff --git a/src/callproc.c b/src/callproc.c
index 51b5a1c4074..abb944c3aad 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -2237,6 +2237,20 @@ the system. */);
2237 Vrcs2log_program_name = build_string ("librcs2log.so"); 2237 Vrcs2log_program_name = build_string ("librcs2log.so");
2238#endif /* !HAVE_ANDROID || ANDROID_STUBIFY */ 2238#endif /* !HAVE_ANDROID || ANDROID_STUBIFY */
2239 2239
2240 DEFVAR_LISP ("command-line-max-length", Vcommand_line_max_length,
2241 doc: /* Maximum length of a command and its arguments on this system.
2242This is measured in characters.
2243Used by `multiple-command-partition-arguments'. Other code calls that
2244function for cases in which it's known to be safe to run the command
2245multiple times on subsequent partitions of the list of arguments.
2246(In a shell script, you might use the `xargs' utility.) */);
2247#if defined _SC_ARG_MAX
2248 /* Divide it by 4 as a crude way to go bytes->characters. */
2249 Vcommand_line_max_length = make_fixnum (sysconf (_SC_ARG_MAX) / 4);
2250#else /* defined _SC_ARG_MAX */
2251 Vcommand_line_max_length = make_fixnum (4096);
2252#endif /* defined _SC_ARG_MAX */
2253
2240 defsubr (&Scall_process); 2254 defsubr (&Scall_process);
2241 defsubr (&Sgetenv_internal); 2255 defsubr (&Sgetenv_internal);
2242 defsubr (&Scall_process_region); 2256 defsubr (&Scall_process_region);