Go to the first, previous, next, last section, table of contents.


Process Buffers

A process can (and usually does) have an associated buffer, which is an ordinary Emacs buffer that is used for two purposes: storing the output from the process, and deciding when to kill the process. You can also use the buffer to identify a process to operate on, since in normal practice only one process is associated with any given buffer. Many applications of processes also use the buffer for editing input to be sent to the process, but this is not built into Emacs Lisp.

Unless the process has a filter function (see section Process Filter Functions), its output is inserted in the associated buffer. The position to insert the output is determined by the process-mark, which is then updated to point to the end of the text just inserted. Usually, but not always, the process-mark is at the end of the buffer.

Function: process-buffer process
This function returns the associated buffer of the process process.

(process-buffer (get-process "shell"))
     => #<buffer *shell*>

Function: process-mark process
This function returns the process marker for process, which is the marker that says where to insert output from the process.

If process does not have a buffer, process-mark returns a marker that points nowhere.

Insertion of process output in a buffer uses this marker to decide where to insert, and updates it to point after the inserted text. That is why successive batches of output are inserted consecutively.

Filter functions normally should use this marker in the same fashion as is done by direct insertion of output in the buffer. A good example of a filter function that uses process-mark is found at the end of the following section.

When the user is expected to enter input in the process buffer for transmission to the process, the process marker separates the new input from previous output.

Function: set-process-buffer process buffer
This function sets the buffer associated with process to buffer. If buffer is nil, the process becomes associated with no buffer.

Function: get-buffer-process buffer-or-name
This function returns the process associated with buffer-or-name. If there are several processes associated with it, then one is chosen. (Currently, the one chosen is the one most recently created.) It is usually a bad idea to have more than one process associated with the same buffer.

(get-buffer-process "*shell*")
     => #<process shell>

Killing the process's buffer deletes the process, which kills the subprocess with a SIGHUP signal (see section Sending Signals to Processes).


Go to the first, previous, next, last section, table of contents.