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.
By default, process output is inserted in the associated buffer.
(You can change this by defining a custom filter function,
see Filter Functions.) 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.
Killing the associated buffer of a process also kills the process.
Emacs asks for confirmation first, if the process’s
process-query-on-exit-flag is non-
nil (see Query Before Exit). This confirmation is done by the function
process-kill-buffer-query-function, which is run from
kill-buffer-query-functions (see Killing Buffers).
This function returns the associated buffer of the process process.
(process-buffer (get-process "shell")) ⇒ #<buffer *shell*>
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.
The default filter function uses this marker to decide where to insert process output, and updates it to point after the inserted text. That is why successive batches of output are inserted consecutively.
Custom filter functions normally should use this marker in the same fashion.
For an example of a filter function that uses
see Process Filter Example.
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.
This function sets the buffer associated with process to
buffer. If buffer is
nil, the process becomes
associated with no buffer.
This function returns a nondeleted process associated with the buffer
specified by buffer-or-name. If there are several processes
associated with it, this function chooses one (currently, the one most
recently created, but don’t count on that). Deletion of a process
delete-process) makes it ineligible for this function to
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 Signals to Processes).