[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.14.1 Process object

Class: <process>
An object to keep the status of a child process. You can create the process object by run-process procedure described below.

Function: run-process command arg ...
Run command with arg in a subprocess, and returns a <process> object. command is searched from the command search path.

Command line arguments args can include the following keyword arguments which specify special handling of the child process:

:input file
:output file
:error file
These arguments controls the subprocess' standard i/o. file may be either a string or a keyword :pipe. If it is a string, the process' standard input, output, or error goes to the named file. If it is :pipe, the process' corresponding standard i/o is connected to a pipe, and the other side of the pipe is available for the calling process.

:wait flag
If flag is true, run-process waits until the subprocess terminates. Othewise the subprocess runs asynchronously and run-process returns immediately, which is the default behavior. Note that if the subprocess is running asynchronously, it is the caller's responsibility to call process-wait at certain timing to correct its exit status.

:fork flag
If flag is true, run-process forks to run the subprocess, which is the default behavior. If flag is false, run-process directly calls sys-exec, so it never returns.

Function: process? obj
== (is-a? obj <process>)

Method: process-pid (process <process>)
Returns the process ID of the subprocess process.

Method: process-command (process <process>)
Returns the command invoked in the subprocess process.

Method: process-input (process <process>)
Method: process-output (process <process>)
Method: process-error (process <process>)
If the process' standard input, output or error is connected to a pipe, returns another end of the pipe, i.e. process-input returns an output port that can feed data to process' stdin, process-output an input port that can read data from process' stdout, and process-error an input port that can read data from process' stderr. If the corresponding i/o is not connected to the pipe, the function returns #f.

 
(let* ((process (run-process "date" :output :pipe))
       (line (read-line (process-output process))))
  (process-wait process)
  line)
 => "Fri Jun 22 22:22:22 HST 2001"

Function: process-alive? process
Returns true if process is alive. Note that Gauche can't know the subprocess' status until it is explicitly checked by process-wait.

Function: process-list
Returns a list of active processes. The process remains active until its exit status is explicitly collected by process-wait.

Function: process-wait process
Obtains exit status of the subprocess process. This suspends execution until process exits.

Function: process-send-signal process signal
Sends a signal signal to the subprocess process. signal must be an exact integer for signal number. See section 6.21.6 Signal, for predefined variables of signals.

Function: process-kill process
Function: process-stop process
Function: process-continue process
Sends SIGKILL, SIGSTOP and SIGCONT to process, respectively.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated by Ken Dickey on November, 28 2002 using texi2html