API Reference


Yet Another Portable Library for Process Handling / Subshell Invokation


  • Struct PIPE
  • Function PIPE
  • Function CLOSE-PIPE (pipe)
  • Function ENVIRONMENT
  • Variable +FDSPECS-DEFAULT+
    '(:input :output :output)
    (make-array (1+ eazy-process::+max-rlimit-constant+) :element-type 'fixnum
                :initial-element -1)
    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.
  • Function SHELL (argv &optional (fdspecs '(:input :output :output)) environments (search t))
  • Class PROCESS
    A class representing a process.
    PID   Reader: PID
    FDS   Reader: %FDS
  • Function FDS (process)
    Returns an fresh array of fds available from lisp process.
  • Function FINALIZE-PROCESS (process &optional (sig 15))
    Waitpid the process. If the process is alive, kill it with SIG first, then with SIGKILL.
  • Function WAIT (process &optional option)
    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.
  • Function FD (process n)
    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.
  • Function FD-AS-PATHNAME (process fd)
    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.
  • Macro WITH-PROCESS ((&whole whole process argv &optional fdspecs environment search) &body body)
    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))
  • Macro WITH-RLIMIT (pairs &body body)
    Append/overwrite the current rlimit resouce limitation. This does not affect the lisp process itself. Only the spawned child process will be affected.
  • Variable *INTERPRETER*
    "sh -c"
    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.
  • Function SHELL-COMMAND (command &key (input "") (result-type :string) (external-format :default) verbose)
    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.

Also exports