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


Synchronous Processes

When a synchronous process is started Jade waits for it to terminated 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.

Function: run-process &optional process-object input-file-name program &rest args
This function starts a process running on the process object process-object. If process-object is undefined a new process object is created by calling the make-process 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').

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 PATH 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 section 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 run-process function can be used to uncompress a file into a buffer.

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


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