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


5.27.1 Process Objects

A process object is a type of Lisp object used to provide a link between a ‘physical’ process running in the operating system and the Lisp system. Each process object consists of a number of values (references to other Lisp objects); these values are used when the object is used to run a subprocess.

Process objects which aren’t currently being used to run a subprocess store the exit value of the last subprocess which was run on that object.

Function: processp object

This function returns true when its argument is a process object.

The programmer-accessible components of a process object are,

Output stream

A normal Lisp output stream (see Output Streams), all data which the subprocess outputs to its stdout channel is copied to this output stream. See Process I/O.

Error stream

A normal Lisp output stream (see Output Streams), all data which the subprocess outputs to its stderr channel is copied to this output stream. Unless explicitly specified error output goes to the stdout stream. See Process I/O.

State change function

A Lisp function, called each time the state of the subprocess being run on the object changes. See Process States.

Program name

The name of the program (a string) to execute when the subprocess is created.

Program arguments

A list of strings defining the arguments which the program executed is given.

Directory

When a subprocess is started its current working directory is set to the directory named by this component of its process object.

Connection type

Asynchronous subprocesses (see Asynchronous Processes) use this component to decide how to connect to the I/O channels of the subprocess. Current options include pseudo-terminals and pipes.

Function: make-process #!optional output-stream state-function directory program args

This functions creates and returns a new process object. No subprocess will be started.

The optional arguments are used to define the values of the components of the new process object, any undefined components will be set to default or null values.

For each component of a process object two functions exist; one to read the component’s value in a specific process object, the other to set the component’s value.

Function: process-prog process

Returns the value of the program name component of the process object process.

Function: set-process-prog process prog-name

Sets the value of the program name component of the process object process to the string prog-name, then returns prog-name.

Function: process-args process

Returns the value of the program arguments component of the process object process.

Function: set-process-args process arg-list

Sets the value of the program arguments component of the process object process to the list arg-list, then returns arg-list.

Function: process-dir process

Returns the value of the directory component of the process object process.

Function: set-process-dir process directory

Sets the value of the directory component of the process object process to the string directory, then returns directory.

Variable: process-environment

This is a list of environment variable definitions, as well as being used by the setenv and getenv functions (see Environment Variables), it also provides the environment of all started subprocesses.

(car process-environment)
    ⇒ "LOGNAME=john"
Function: active-processes

Returns a list containing all active (i.e. running or stopped) process objects.


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