** 'process-contact' now takes an optional NO-BLOCK argument to allow
not waiting for a process to be set up.
+---
+** New variable 'read-process-output-max' controls sub-process throughput.
+This variable determines how many bytes can be read from a sub-process
+in one read operation. The default, 4096 bytes, was previously a
+hard-coded constant. Setting it to a larger value might enhance
+throughput of reading from sub-processes that produces vast
+(megabytes) amounts of data in one go.
+
+++
** The new user option 'quit-window-hook' is now run first when
executing the 'quit-window' command.
Yield number of decoded characters read,
or -1 (setting errno) if there is a read error.
- This function reads at most 4096 characters.
+ This function reads at most read_process_output_max bytes.
If you want to read all available subprocess output,
you must call it repeatedly until it returns zero.
struct Lisp_Process *p = XPROCESS (proc);
struct coding_system *coding = proc_decode_coding_system[channel];
int carryover = p->decoding_carryover;
- enum { readmax = 4096 };
+ ptrdiff_t readmax = clip_to_bounds (1, read_process_output_max, PTRDIFF_MAX);
ptrdiff_t count = SPECPDL_INDEX ();
Lisp_Object odeactivate;
- char chars[sizeof coding->carryover + readmax];
+ char *chars;
+
+ USE_SAFE_ALLOCA;
+ chars = SAFE_ALLOCA (sizeof coding->carryover + readmax);
if (carryover)
/* See the comment above. */
if (nbytes <= 0)
{
if (nbytes < 0 || coding->mode & CODING_MODE_LAST_BLOCK)
- return nbytes;
+ return SAFE_FREE_UNBIND_TO (count, nbytes);
coding->mode |= CODING_MODE_LAST_BLOCK;
}
/* Handling the process output should not deactivate the mark. */
Vdeactivate_mark = odeactivate;
- unbind_to (count, Qnil);
+ SAFE_FREE_UNBIND_TO (count, Qnil);
return nbytes;
}
doc: /* Name of external socket passed to Emacs, or nil if none. */);
Vinternal__daemon_sockname = Qnil;
+ DEFVAR_INT ("read-process-output-max", read_process_output_max,
+ doc: /* Maximum number of bytes to read from subprocess in a single chunk.
+Enlarge the value only if the subprocess generates very large (megabytes)
+amounts of data in one go. */);
+ read_process_output_max = 4096;
+
DEFSYM (Qinternal_default_interrupt_process,
"internal-default-interrupt-process");
DEFSYM (Qinterrupt_process_functions, "interrupt-process-functions");