2017-08-27

(sph process)

execute programs and evaluate shell or scheme code

part of sph-lib

import name

(sph process)

exports

call-with-working-directory

procedure

signature

path p ->

execute

procedure

signature

a ... ->

execute->file

procedure

signature

target-path command command-arguments ... ->

string (string ...) string ->

description

apply "system*" with command and command-arguments and set standard-output to a file at target-path. the file is either created or overwritten

execute->port

procedure

signature

port path arguments ... ->

port string string ... ->

description

execute program at "path" with "arguments" and write everything that is written to standard output by the program to "port"

execute->string

procedure

signature

command command-arguments ... ->

string (string ...) string ->

description

apply "system*" with command and command-arguments and result in a string for the output the program wrote to standard output

execute-and

procedure

signature

a rest ... ->

(string ...) ... -> system*-result

description

takes lists of arguments to system* and calls system* for each of these arguments.

if one call returns with a non-zero exit value the processing stops and returns the result of system*

execute-and-check-result

procedure

signature

path arguments ... ->

string (string ...) -> boolean

description

execute command with system*, check exit-status and return true if it is zero, false otherwise.

execute-with-pipe

procedure

signature

proc mode path arguments ... ->

procedure integer string list -> any

description

execute a program with a pipe connected to its standard-output and/or standard-input and pass it as one port to "proc".

mode can be one of the guile variables OPEN_READ OPEN_WRITE OPEN_BOTH

exit-value-zero?

procedure

signature

system-result ->

process-eval

procedure

signature

code proc ->

(scheme-expression ...) procedure:{process-output-port -> any} -> any

description

evaluate code in a new guile process, independent from the current process (no shared environment)

and pass a port for the standard output of the process to proc

process-finish

procedure

signature

pid ->

integer -> boolean

description

use waitpid without extra options and return the exit status integer.

waitpid waits for the termination of the process and afterwards frees the resources of the child process

which prevents it from staying in zombie status

process-finish-success?

procedure

signature

pid ->

process-replace

procedure

signature

program-path arguments ... ->

description

replaces the current process image with the execution of the program at program-path.

executes programs conventionally with program-path as the first argument.

uses execl

process-replace-e

procedure

signature

env path arguments ... ->

(string:"name=value" ...) string string ... ->

description

like process-replace but the environment variables of the process are passed with the env parameter.

to use the current environment variables the (environ) procedure can be used - it creates output in the expected format for "env".

uses execle

process-replace-p

procedure

signature

program-name/path arguments ... ->

description

like process-replace-without-search except that if the path to the program to execute does not start with a slash

it is searched in the directories in the PATH environment variable.

uses execlp

process-replace-pe

procedure

signature

env name/path arguments ... ->

(string:"name=value" ...) string string ... ->

description

like process-replace-e except that if the path to the program to execute does not start with a slash

it is searched in the directories in the PATH environment variable

shell-eval

procedure

signature

[a] ->

shell-eval->string

procedure

signature

command-str ->

string -> string

description

evaluate command-string with sh and return the resulting string

shell-eval-and-check-result

procedure

signature

command-str ->

string -> boolean

description

execute command with system, check exit-status and return true if it is zero, false otherwise.

sph-process-description

variable

tags: programming guile documentation library scheme sph-lib q1 process highlight sph-process