GNU Info

Info Node: (elisp)Output from Processes

(elisp)Output from Processes


Next: Sentinels Prev: Signals to Processes Up: Processes
Enter node , (file) or (file)node

Receiving Output from Processes
===============================

   There are two ways to receive the output that a subprocess writes to
its standard output stream.  The output can be inserted in a buffer,
which is called the associated buffer of the process, or a function
called the "filter function" can be called to act on the output.  If
the process has no buffer and no filter function, its output is
discarded.

   Output from a subprocess can arrive only while Emacs is waiting: when
reading terminal input, in `sit-for' and `sleep-for' (Note: Waiting),
and in `accept-process-output' (Note: 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 that
waits.

   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.

   Subprocess output is normally decoded using a coding system before
the buffer or filter function receives it, much like text read from a
file.  You can use `set-process-coding-system' to specify which coding
system to use (Note: Process Information).  Otherwise, the coding
system comes from `coding-system-for-read', if that is non-`nil'; or
else from the defaulting mechanism (Note: Default Coding Systems).

   *Warning:* Coding systems such as `undecided' which determine the
coding system from the data do not work entirely reliably with
asynchronous subprocess output.  This is because Emacs has to process
asynchronous subprocess output in batches, as it arrives.  Emacs must
try to detect the proper coding system from one batch at a time, and
this does not always work.  Therefore, if at all possible, use a coding
system which determines both the character code conversion and the end
of line conversion--that is, one like `latin-1-unix', rather than
`undecided' or `latin-1'.

Process Buffers
If no filter, output is put in a buffer.
Filter Functions
Filter functions accept output from the process.
Accepting Output
Explicitly permitting subprocess output.
Waiting for subprocess output.

automatically generated by info2www version 1.2.2.9