The output that a subprocess writes to its standard output stream is passed to a function called the filter function. The default filter function simply inserts the output into a buffer, which is called the associated buffer of the process (see Process Buffers). If the process has no buffer then the default filter discards the output.
When a subprocess terminates, Emacs reads any pending output, then stops reading output from that subprocess. Therefore, if the subprocess has children that are still live and still producing output, Emacs won’t receive that output.
Output from a subprocess can arrive only while Emacs is waiting: when
reading terminal input (see the function
sleep-for (see Waiting), and in
accept-process-output (see Accepting Output). This
minimizes the problem of timing errors that usually plague parallel
programming. For example, you can safely create a process and only
then specify its buffer or filter function; no output can arrive
before you finish, if the code in between does not call any primitive
On some systems, when Emacs reads the output from a subprocess, the
output data is read in very small blocks, potentially resulting in
very poor performance. This behavior can be remedied to some extent
by setting the variable
process-adaptive-read-buffering to a
nil value (the default), as it will automatically delay reading
from such processes, thus allowing them to produce more output before
Emacs tries to read it.
It is impossible to separate the standard output and standard error streams of the subprocess, because Emacs normally spawns the subprocess inside a pseudo-TTY, and a pseudo-TTY has only one output channel. If you want to keep the output to those streams separate, you should redirect one of them to a file—for example, by using an appropriate shell command.
|• Process Buffers:||By default, output is put in a buffer.|
|• Filter Functions:||Filter functions accept output from the process.|
|• Decoding Output:||Filters can get unibyte or multibyte strings.|
|• Accepting Output:||How to wait until process output arrives.|