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

  • ext
    • clib
      • socket.pl
      • 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
      • 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
      • streampool.pl -- Input multiplexing
      • udp_broadcast.pl -- A UDP broadcast proxy
      • streaminfo.pl
      • crypt.pl
      • prolog_server.pl
      • cgi.pl -- Read CGI parameters
 detach_IO(+Stream) is det
This predicate is intended to create Unix deamon processes. It performs two actions.
  1. The I/O streams user_input, user_output and user_error are closed if they are connected to a terminal (see tty property in stream_property/2). Input streams are rebound to a dummy stream that returns EOF. Output streams are reboud to forward their output to Stream.
  2. The process is detached from the current process-group and its controlling terminal. This is achieved using setsid() if provided or using ioctl() TIOCNOTTY on /dev/tty.

To ignore all output, it may be rebound to a null stream. For example:

      ...,
      open_null_stream(Out),
      detach_IO(Out).

The detach_IO/1 should be called only once per process. Subsequent calls silently succeed without any side effects.

See also
- detach_IO/0 and library(syslog).