/usr/lib/swipl/library/ext/clib/unix.pl
All Application Manual Name SummaryHelp

  • ext
    • clib
      • socket.pl -- Network socket (TCP and UDP) library
      • uid.pl
      • unix.pl -- Unix specific operations
        • fork/1
        • fork_exec/1
        • exec/1
        • wait/2
        • kill/2
        • pipe/2
        • dup/2
        • detach_IO/1
        • detach_IO/0
        • prctl/1
        • sysconf/1
      • syslog.pl -- Unix syslog interface
      • memfile.pl
      • time.pl -- Time and alarm library
      • uri.pl -- Process URIs
      • filesex.pl -- Extended operations on files
      • uuid.pl -- Universally Unique Identifier (UUID) Library
      • sha.pl -- SHA secure hashes
      • process.pl -- Create processes and redirect I/O
      • hash_stream.pl -- Maintain a hash on a stream
      • md5.pl -- MD5 hashes
      • rlimit.pl
      • mallocinfo.pl -- Memory allocation details
      • prolog_stream.pl -- A stream with Prolog callbacks
      • crypt.pl
      • streaminfo.pl
      • udp_broadcast.pl -- A UDP broadcast proxy
      • cgi.pl -- Read CGI parameters
      • streampool.pl -- Input multiplexing
 fork(-Pid) is det
Clone the current process into two branches. In the child, Pid is unified to child. In the original process, Pid is unified to the process identifier of the created child. Both parent and child are fully functional Prolog processes running the same program. The processes share open I/O streams that refer to Unix native streams, such as files, sockets and pipes. Data is not shared, though on most Unix systems data is initially shared and duplicated only if one of the programs attempts to modify the data.

Unix fork() is the only way to create new processes and fork/1 is a simple direct interface to it.

Errors
- permission_error(fork, process, main) is raised if the calling thread is not the only thread in the process. Forking a Prolog process with threads will typically deadlock because only the calling thread is cloned in the fork, while all thread synchronization are cloned.