Next: Creating Synchronous Subprocesses, Up: Processes [Index]
There are three primitives that create a new subprocess in which to run a program.
call-process
creates a synchronous process
call-process-region
creates a synchronous process
make-process
creates an asynchronous process and returns a process object
The three functions are called in similar fashions; their common arguments are described here first.
In all cases, the functions specify the program to be run.
The filename may contain ‘~’, ‘.’, and ‘..’. If the file name is relative, the
variable ‘exec-path’ contains a list of directories to search. Emacs
initializes ‘exec-path’ when it starts up, based on the value of the
environment variable ‘PATH’. nil
in the list refers to default-directory
.
The variable exec-directory
can also supply a directory to search.
Your exec-path
has the contents:
Users/lolh.opam/ocaml-base-compiler/bin | /usr/local/work/workbin | /usr/local/dev/bin | /opt/local/bin | /opt/local/sbin | /usr/local/bin | /usr/local/sbin | /usr/bin | /bin | /usr/sbin | /sbin | /usr/local/smlnj/bin | /Library/TeX/texbin | /usr/local/go/bin | /usr/local/MacGPG2/bin | /opt/X11/bin |
The value of this variable is a string, the name of a directory that contains programs that come with GNU Emacs and are intended for Emacs to invoke. The program ‘movemail’ is an example of such a program; Rmail uses it to fetch new mail from an inbox.
Your exec-directory
has the value:
/Applications/Emacs.app/Contents/MacOS/libexec/
Use the function ‘substitute-in-file-name’ to perform environment variable substitutions (‘$HOME’).
Substitute environment variables referred to in FILENAME. ‘$FOO’ where FOO is an environment variable name means to substitute the value of that variable.
(substitute-in-file-name "$HOME/foo") ⇒ "/xcssun/users/rms/foo"
Each of the subprocess-creating functions has a BUFFER-OR-NAME argument that specifies where the output from the program will go. It should be a buffer or a buffer name; if it is a buffer name, that will create the buffer if it does not already exist. It can also be ‘nil’, which says to discard the output, unless a custom filter function handles it.
For synchronous processes, you can send the output to a file instead of a buffer.
By default, both standard output and standard error streams go to the same destination, but all the 3 primitives allow optionally to direct the standard error stream to a different destination.
All three of the subprocess-creating functions allow to specify command-line arguments for the process to run. The command-line arguments must all be strings, and they are supplied to the program as separate argument strings.
The subprocess inherits its environment from Emacs, but you can specify overrides for it with ‘process-environment’.
The subprocess gets its current directory from the value of ‘default-directory’.
Next: Creating Synchronous Subprocesses, Up: Processes [Index]