Node: Processes, Next: , Previous: Hash Tables, Up: Standard Procedures



Processes

STKLOS provides access to Unix processes as first class objects. Basically, a process contains several informations such as the standard system process identification (aka PID on Unix Systems), the files where the standard files of the process are redirected.

run-process command p1 p2 ... STKLOS Procedure
run-process creates a new process and run the executable specified in command. The p correspond to the command line arguments. The following values of p have a special meaning:
  • :input permits to redirect the standard input file of the process. Redirection can come from a file or from a pipe. To redirect the standard input from a file, the name of this file must be specified after :input. Use the special keyword :pipe to redirect the standard input from a pipe.
  • :output permits to redirect the standard output file of the process. Redirection can go to a file or to a pipe. To redirect the standard output to a file, the name of this file must be specified after :output. Use the special keyword :pipe to redirect the standard output to a pipe.
  • :error permits to redirect the standard error file of the process. Redirection can go to a file or to a pipe. To redirect the standard error to a file, the name of this file must be specified after error. Use the special keyword :pipe to redirect the standard error to a pipe.
  • :wait must be followed by a boolean value. This value specifies if the process must be run asynchronously or not. By default, the process is run asynchronously (i.e. :wait is #f).
  • :host must be followed by a string. This string represents the name of the machine on which the command must be executed. This option uses the external command rsh. The shell variable PATH must be correctly set for accessing it without specifying its abolute path.
  • :fork must be followed by a boolean value. This value specifies if a fork system call must be done before running the process. If the process is run without fork the Scheme program is lost. This feature mimics the "exec" primitive of the Unix shells. By default, a fork is executed before running the process (i.e. :fork is #t). This option works on Unix implementations only.

The following example launches a process which executes the Unix command ls with the arguments -l and /bin. The lines printed by this command are stored in the file /tmp/X

          (run-process "ls" "-l" "/bin" :output "/tmp/X")
          

process? obj STKLOS Procedure
Returns #t if obj is a process , otherwise returns #f.

process-alive? proc STKLOS Procedure
Returns #t if process proc is currently running, otherwise returns #f.

process-pid proc STKLOS Procedure
Returns an integer which represents the Unix identification (PID) of the processus.

process-input proc STKLOS Procedure
process-input proc STKLOS Procedure
process-input proc STKLOS Procedure
Returns the file port associated to the standard input, output or error of proc, if it is redirected in (or to) a pipe; otherwise returns #f. Note that the returned port is opened for reading when calling process-output or process-error; it is opened for writing when calling process-input.

process-wait proc STKLOS Procedure
Stops the current process (the Scheme process) until proc completion. Process-wait returns #f when proc is already terminated; it returns #t otherwise.

process-exit-status proc STKLOS Procedure
Returns the exit status of proc if it has finished its execution; returns #f otherwise.

process-send-signal proc sig STKLOS Procedure
Sends the integer signal sig to proc. Since value of sig is system dependant, use the symbolic defined signal constants to make your program independant of the running system (see see signals). The result of process-send-signal is void.

process-kill proc STKLOS Procedure
Kills (brutally) process. The result of process-kill is void. This procedure is equivalent to
          (process-send-signal process 'SIGTERM)
          

process-stop proc STKLOS Procedure
process-continue proc STKLOS Procedure
Process-stop stops the execution of proc and process-continue resumes its execution. They are equivalent, respectively, to
          (process-send-signal process 'SIGSTOP)
          (process-send-signal process 'SIGCONT)
          

process-list STKLOS Procedure
Returns the list of processes which are currently running (i.e. alive).