Next: , Up: Creating Synchronous Subprocesses   [Index]


I.1.2.1 call-process—a primitive

Function: call-process program &optional infile destination display &rest args

This function calls PROGRAM and waits for it to finish.

The current working directory of the subprocess is set to the current buffer’s value of ‘default-directory’ if that is local (as determined by ‘unhandled-file-name-directory’), or "~" otherwise. If you want to run a process in a remote directory use ‘process-file’.

infile

The standard input for the new process comes from file INFILE if INFILE is not ‘nil’, and from the null device otherwise.

destination

The argument DESTINATION says where to put the process output. Here are the possibilities:

a buffer
a buffer name (a string)
t

Insert the output in the current buffer, before point.

nill

Discard the output

0

Discard the output, and return ‘nil’ immediately without waiting for the subprocess to finish.

(:file FILE-NAME)

Send the output to the file name specified, overwriting it if it already exists.

(REAL-DESTINATION ERROR-DESTINATION)

Keep the standard output stream separate from the standard error stream; deal with the ordinary output as specified by REAL-DESTINATION, and dispose of the error output according to ERROR-DESTINATION. If ERROR-DESTINATION is ‘nil’, that means to discard the error output, ‘t’ means mix it with the ordinary output, and a string specifies a file name to redirect error output into.

You can’t directly specify a buffer to put the error output in; that is too difficult to implement. But you can achieve this result by sending the error output to a temporary file and then inserting the file into a buffer when the subprocess finishes.

display

If DISPLAY is non-‘nil’, then ‘call-process’ redisplays the buffer as output is inserted. Otherwise the function ‘call-process’ does no redisplay, and the results become visible on the screen only when Emacs redisplays that buffer in the normal course of events.

args

The remaining arguments, ARGS, are strings that specify command line arguments for the program. Each string is passed to PROGRAM as a separate argument.

Return Value

The value returned by ‘call-process’ (unless you told it not to wait) indicates the reason for process termination. A number gives the exit status of the subprocess; 0 means success, and any other value means failure. If the process terminated with a signal, ‘call-process’ returns a string describing the signal. If you told ‘call-process’ not to wait, it returns ‘nil’.


Next: call-process-region—a primitive, Up: Creating Synchronous Subprocesses   [Index]