This library offers predicates to create, communicate, and synchronize with child processes. The child processes are duplicates of the parent process, based on the fork() function from POSIX-compatible operating systems (see man page for a precise description of the non-inherited process attributes).
The child process can execute a given goal (in a clone of the parent process) or start an external program.
Contrary to threads, processes have a separate address space and communication must be performed via inter-process communication mechanisms. This is useful for executing external programs, or implementing coarse-grained parallelism and concurrency.
Usage:
A process handler
The process standard input, output, and error file descriptors (streams from the Prolog side) can be bound to several process_channel/1:
The environment of the process can be modified with the following options:
Usage:
Options that control command execution
Usage:process_call(Cmd,Args,Opts)
Execute a command in a child process, where Cmd is the executable path. Use path(Exec) for executing a program Exec reachable from the PATH environment variable
Usage:process_pid(Process,Pid)
The POSIX PID of the process Process.
Usage:process_is_joined(Process)
The process has already been joined.
Usage:process_join(Process)
Wait for completion of process Process.
Usage:process_terminate(Process)
Sends POSIX signal SIGTERM to the process Process, which asks politely for process termination.
Usage:process_kill(Process)
Sends POSIX signal SIGKILL to the process Process, which forces process termination.
Usage:process_send_signal(Process,Signal)
Sends POSIX signal Signal to process Process.
Usage:process_fork(Goal,Opts)
Execute Goal in a forked process.
Usage:process_pipe(Cmd,Opts)
Execute the list Cmds of process_call/3, connecting standard input and output of consecutive processes with pipes.
Options are passed as follows: input redirection options are applied to the first process; output redirection and status are applied to the last process; the rest of options are applied to all commands. Background execution is not currently supported (see internal documentation for details).