:- use_module(library(process)).(can be autoloaded)
vfork. If the method is
spawnbut this cannot be used because it is either not supported by the OS or the
cwd(Dir)option is given
The problem is to be understood as follows. The official portable and
safe method to create a process is using the
call. This call however copies the process page tables and get seriously
slow as the (Prolog) process is multiple giga bytes large.
Alternatively, we may use
vfork() which avoids copying the
process space. But, the safe usage as guaranteed by the POSIX standard
vfork() is insufficient for our purposes. On practical
systems your mileage may vary. Modern posix systems also provide
which provides a safe and portable alternative for the
exec() sequence that may be implemented using
or may use a fast but safe alternative. Unfortunately
doesn't support the option to specify the working directory for the
child and we cannot use working_directory/2
as the working directory is shared between threads.
Summarizing, the default is safe and tries to be as fast as possible.
On some scenarios and on some OSes it is possible to do better. It is
generally a good idea to avoid using the
cwd(Dir) option of process_create/3
as without we can use