| Did you know ... | Search Documentation: |
| Predicate exec/1 |
exec(+Command)execvp(). Here are some examples:
exec(ls('-l'))exec('/bin/ls'('-l', '/home/jan'))
Unix exec() is the only way to start an executable file
executing. It is commonly used together with fork/1.
For example to start netscape on an URL in the background, do:
run_netscape(URL) :-
( fork(child),
exec(netscape(URL))
; true
).
Using this code, netscape remains part of the process-group of the invoking Prolog process and Prolog does not wait for netscape to terminate. The predicate wait/2 allows waiting for a child, while detach_IO/0 disconnects the child as a deamon process.