Next: , Previous: , Up: Processes   [Contents][Index]

5.27.3 Synchronous Processes

When a synchronous process is started Librep waits for it to terminate before continuing; they are usually used when a Lisp program must invoke an external program as part of its function, i.e. the auto-compression feature runs the compression program gzip synchronously when it needs to compress a buffer.

Unlike asynchronous processes their is no choice between pipes and pseudo-terminals for connecting to a subprocess. Instead, it is possible to link the stdin channel of a synchronous process to a named file.

For shell command invocation, see See Shell Commands.

Function: call-process #!optional process input-file-name program #!rest args

This function starts a process running on the process object process. If process is undefined a new process object is created by calling the make function.

If defined, the string input-file-name names the file to connect to the standard input of the subprocess, otherwise the subprocess’ input comes from the null device (/dev/null on UNIX).

The optional arguments program and args define the name of the program to invoke and any arguments to pass to it. The program will be searched for in all directories listed in the process-environment variable.

If any of the optional parameters are unspecified they should have been set in the process-object prior to calling this function.

After successfully creating the new subprocess, this function simply copies any output from the process to the output stream defined by the output stream component of the process object. When the subprocess exits its exit-value is returned (an integer). Note that the exit-value is the value returned by the process-exit-value function, see Process Information.

If, for some reason, the new subprocess can’t be created an error of type process-error is signalled.

The following function definition is taken from the gzip.jl file, it shows how the call-process function can be used to uncompress a file into a buffer (for Jade).

;; Uncompress FILE-NAME into the current buffer
(defun gzip-uncompress (file-name)
      ((proc (make-process (current-buffer))))
    (message (concat "Uncompressing `" file-name "'") t)
    ;; gunzip can do .Z files as well
    (unless (zerop (call-process proc nil "gunzip" "-c" file-name))
      (signal 'file-error (list "Can't gunzip file" file-name)))))

The user is able to interrupt synchronous subprocesses (for example if they seem to have got wedged somehow). Each time a user-interrupt is received by Librep (i.e. the INT signal), a stronger signal is sent to the subprocess. First an interrupt signal, then a termination signal, before finally a non-ignoreable quit signal is sent.

Next: , Previous: , Up: Processes   [Contents][Index]