This is the eazy-process Reference Manual, version 0.1, generated automatically by Declt version 4.0 beta 2 "William Riker" on Sun Dec 08 17:59:30 2024 GMT+0.
eazy-process/eazy-process.asd
eazy-process/src/package.lisp
eazy-process/src/mktempfifo.lisp
eazy-process/src/pipe.lisp
eazy-process/src/environ.lisp
eazy-process/src/specials.lisp
eazy-process/src/fdspec.lisp
eazy-process/src/shell.lisp
eazy-process/src/process.lisp
eazy-process/src/macros.lisp
eazy-process/src/resources.lisp
eazy-process/compat/trivial-shell.lisp
The main system appears first, followed by any subsystem dependency.
eazy-process
Yet Another Portable Library for Process Handling / Subshell Invokation
Masataro Asai
MIT
In ‘run-program‘ interface in the popular
implementations, piping between subprocesses are hard. It requires either
reading the entire output stream and packing the contents as a new
string-input-stream, or using some other implementation-specific
functions. Also, compatibility libraries e.g. trivial-shell or
inferior-shell, often depend on these functions, implying the same
problem. Iolib also has ‘run-program‘ that allows easy piping, but it is
restricted to 3 fds: ‘input,output,error‘.
Eazy-process provides a clean, declarative and thin layer to the processes. It depends on the concept of ’everything is a file’ and do not provide interfaces to streams.
0.1
iterate
(system).
alexandria
(system).
cffi
(system).
trivia
(system).
trivia.ppcre
(system).
iolib/syscalls
(system).
trivial-garbage
(system).
cl-ppcre
(system).
cl-rlimit
(system).
Modules are listed depth-first from the system components tree.
eazy-process/src
eazy-process
(system).
package.lisp
(file).
mktempfifo.lisp
(file).
pipe.lisp
(file).
environ.lisp
(file).
specials.lisp
(file).
fdspec.lisp
(file).
shell.lisp
(file).
process.lisp
(file).
macros.lisp
(file).
resources.lisp
(file).
eazy-process/compat
src
(module).
eazy-process
(system).
trivial-shell.lisp
(file).
Files are sorted by type and then listed depth-first from the systems components trees.
eazy-process/eazy-process.asd
eazy-process/src/package.lisp
eazy-process/src/mktempfifo.lisp
eazy-process/src/pipe.lisp
eazy-process/src/environ.lisp
eazy-process/src/specials.lisp
eazy-process/src/fdspec.lisp
eazy-process/src/shell.lisp
eazy-process/src/process.lisp
eazy-process/src/macros.lisp
eazy-process/src/resources.lisp
eazy-process/compat/trivial-shell.lisp
eazy-process/eazy-process.asd
eazy-process
(system).
eazy-process/src/mktempfifo.lisp
package.lisp
(file).
src
(module).
mktempfifo
(function).
eazy-process/src/pipe.lisp
mktempfifo.lisp
(file).
src
(module).
close-pipe
(function).
pipe
(function).
pipe
(structure).
copy-pipe
(function).
make-pipe
(function).
pipe-p
(function).
pipe-read
(reader).
(setf pipe-read)
(writer).
pipe-write
(reader).
(setf pipe-write)
(writer).
eazy-process/src/environ.lisp
pipe.lisp
(file).
src
(module).
environment
(function).
eazy-process/src/specials.lisp
environ.lisp
(file).
src
(module).
*rlimit-resources*
(special variable).
+fdspecs-default+
(special variable).
+max-rlimit-constant+
(special variable).
eazy-process/src/fdspec.lisp
specials.lisp
(file).
src
(module).
%open
(function).
%pipe
(function).
canonicalize-fdspec
(function).
dclose
(function).
eazy-process/src/shell.lisp
fdspec.lisp
(file).
src
(module).
shell
(function).
%exec
(function).
%execv
(function).
%execvp
(function).
%in-child
(function).
%in-parent
(function).
%setenv
(function).
make-c-char*
(function).
eazy-process/src/process.lisp
shell.lisp
(file).
src
(module).
fd
(function).
fd-as-pathname
(function).
fds
(function).
finalize-process
(function).
pid
(reader method).
print-object
(method).
process
(class).
wait
(function).
%close-fd-safely
(function).
%fds
(reader method).
%finalize-process
(function).
%make-process
(function).
eazy-process/src/macros.lisp
process.lisp
(file).
src
(module).
with-process
(macro).
eazy-process/src/resources.lisp
macros.lisp
(file).
src
(module).
with-rlimit
(macro).
eazy-process/compat/trivial-shell.lisp
compat
(module).
*bourne-compatible-shell*
(symbol macro).
*interpreter*
(special variable).
shell-command
(function).
check-alive
(function).
close-fd
(function).
io-loop-string
(function).
try-read-write-char
(function).
with-retry-open-file
(macro).
Packages are listed by definition order.
eazy-process
alexandria
.
cffi
.
cl-rlimit
.
common-lisp
.
iterate
.
trivia.level2
.
trivia.ppcre
.
*bourne-compatible-shell*
(symbol macro).
*interpreter*
(special variable).
*rlimit-resources*
(special variable).
+fdspecs-default+
(special variable).
close-pipe
(function).
environment
(function).
fd
(function).
fd-as-pathname
(function).
fds
(function).
finalize-process
(function).
pid
(generic reader).
pipe
(function).
pipe
(structure).
process
(class).
shell
(function).
shell-command
(function).
wait
(function).
with-process
(macro).
with-rlimit
(macro).
%close-fd-safely
(function).
%exec
(function).
%execv
(function).
%execvp
(function).
%fds
(generic reader).
%finalize-process
(function).
%in-child
(function).
%in-parent
(function).
%make-process
(function).
%open
(function).
%pipe
(function).
%setenv
(function).
+max-rlimit-constant+
(special variable).
canonicalize-fdspec
(function).
check-alive
(function).
close-fd
(function).
copy-pipe
(function).
dclose
(function).
io-loop-string
(function).
make-c-char*
(function).
make-pipe
(function).
mktempfifo
(function).
pipe-p
(function).
pipe-read
(reader).
(setf pipe-read)
(writer).
pipe-write
(reader).
(setf pipe-write)
(writer).
try-read-write-char
(function).
with-retry-open-file
(macro).
Definitions are sorted by export status, category, package, and then by lexicographic order.
Command line string which is invoked in order to run the subshell. Default value is "sh -c".
The value is then followed by the command specified in shell-command, e.g. ,
when command = ’ls -la’, the running command is "sh -c ’ls -la’".
It provides the ability to call the interpreters like perl/AWK easily.
The name/path of the interpreter must be separated by spaces from the options like ’-c’.
Do not use complex things like — LANG=C sh . The first word is always considered the pathname.
If you want to do complicated stuff, then do it inside the interpreter.
The process is forked, then the child process calls execvp with the name of
the interpreter. (This is defined in function ‘eazy-process:shell’.) The
actual pathname of the intepreter can be resolved using PATH environment
variable.
A vector of rlimit resource value, where the index suggests +rlimit-XXX+, which is an integer (usually below 16)
This value does not affect the lisp process itself; The effect is applied to the child process only.
Rather than modifying this variable directly, use ‘with-rlimit’ instead.
Spawn a process, bind the process to PROCESS,
execute the body and finalize (= kill and wait w/ nohang) the process.
BODY works as an implicit progn, and the return value is that of the progn.
It does not synchronously wait the process. Therefore, it is the user’s
responsibility to inhibit the early termination of the process.
The aim of finalization is to release the resources of the process e.g. file descriptor and pipes.
Example:
(with-open-process (p ("sleep" "10"))
(print :waiting)
(wait p))
Append/overwrite the current rlimit resouce limitation.
This does not affect the lisp process itself.
Only the spawned child process will be affected.
Returns the file descriptor of the lisp process.
The returned fd is connected to the n-th fd of the child process through a pipe.
Example:
(fd P 1) ; –> 5
This means that the 5’th fd of the lisp process is connected to the 1st fd of the process P.
Return the pathname for each file descriptor.
Lisp can read/write to each fd by opening this file.
Since the buffer size of file-stream is implementation-dependent, and the call to cl:read might cache a considerable amount of characters from the file, we are not able to ensure that the same file can be opened more than once.
Even if you just cl:open the file and just cl:read-char the stream,
it might read the entire characters of the file into the buffer as a side-effect.
We just advise you not to open the file more than once.
Returns an fresh array of fds available from lisp process.
Waitpid the process. If the process is alive, kill it with SIG first, then with SIGKILL.
Asynchronously execute ‘argv’ using fork(2) and ‘execve’
family of system calls, returns a process structure object.
ARGV is a sequence of strings. Each string is converted to null-terminated
C strings char* ARGV and passed to execvp. The first element is also
passed to execvp as the pathname of the executable.
FDSPECS is a sequence specifying how the child process should handle its output.
For the documentation of fd-specifier see ‘+fdspecs-default+’.
Example: (:in :out :out) , (5 :out 8)
Each element in FDSPECS corresponds to each file descriptor of the child process.
When an i-th element of FDSPECS is a symbol, then a new pipe(2) is created for each i.
The i-th fd of the child process p1 is associated with the correct end of the new pipe,
the other end of the pipe is readable/writable from lisp from the process interface.
(see the documentation of class PROCESS.)
When an i-th element of FDSPECS is an integer j,
then it should be the lisp end of a pipe connected to some other child process p2.
(not the normal fd of the lisp process, like 0,1,2)
The i-th fd of p1 is connected to this pipe,
then p1 and p2 can exchange the data each other.
When this happens, lisp process should not read from this pipe
(or the data will not be sent to the destination of the pipe).
For that purpose, add a layer like ‘tee’.
When ENVIRONMENT is specified, it is passed to execve/execvpe.
It should be a list of strings ("NAME1=VALUE1" "NAME2=VALUE2")
or an alist (("NAME1" . "VALUE1") ...).
When SEARCH is t, it uses execvp/execvpe. (==executable is searched through PATH)
On error during system call in the parent process, iolib.syscalls:syscall-error is signalled.
In the child process, the system call failure result in error status 203.
FIXME: this might not be good.
simple interface compatible to trivial-shell @
https://github.com/gwkkwg/trivial-shell.git.
returns (values output error-output exit-status).
The input is read from the :input key argument.
Additional functionality:
:external-format — specifies the decoding of the output.
option is one of :nohang, :untraced, :continued.
Returns a value of the following signature:
(list (boolean ifexited)
(integer exitstatus)
(boolean ifsignalled)
(integer termsig)
(boolean coredump)
(boolean ifstopped)
(integer stopsig)
(boolean ifcontinued)
(integer status)).
When the value is inappropriate as defined in man wait(2),
some integer values may return NIL.
When :nohang is specified but no child has changed its state,
then it returns NIL instead.
‘wait(0)’, i.e. wait for any children, is not available.
A class representing a process.
%fds
.
pid
.
print-object
.
True finalizer of a process object. However,
This function should not contain reference to the process itself
because it prevents process object from GC-ing.
if the child process died of errno, the exit value is that value
ANSI CL standard:
if-does-not-exist—one of :error, :create, or nil.
The default is
:error if direction is :input or if-exists is :overwrite or :append
:create if direction is :output or :io, and if-exists is neither :overwrite nor :append;
or nil when direction is :probe.
Take an fd-specifier and return a cons of (parent-fn . child-fn) where
both parent-fn and child-fn are closures of 1 arg, the fd on the child end.
Each function runs a job that should be done in the context of
parent/child process.
if FD is specified and the direction is not specified, use the default
direction of that fd by default. For FD > 2, there is no default direction
and it signals an error.
Parent-fn should return the fd of the parent-end.
Duplicate the old fd, set it to the new fd, then close the old fd
read
.
Jump to: | %
(
C D E F G I M P S T W |
---|
Jump to: | %
(
C D E F G I M P S T W |
---|
Jump to: | *
+
F P R S W |
---|
Jump to: | *
+
F P R S W |
---|
Jump to: | C E F M P R S T |
---|
Jump to: | C E F M P R S T |
---|