4.17.2 ISO Input and Output Streams
AllApplicationManualNameSummaryHelp

  • Documentation
    • Reference manual
      • Built-in Predicates
        • Input and output
          • ISO Input and Output Streams
            • open/4
            • open/3
            • open_null_stream/1
            • close/1
            • close/2
            • stream_property/2
            • current_stream/3
            • is_stream/1
            • stream_pair/3
            • set_stream_position/2
            • stream_position_data/3
            • seek/4
            • set_stream/2
            • set_prolog_IO/3
            • set_system_IO/3
    • Packages
Availability:built-in
set_system_IO(+In, +Out, +Error)
Bind the given streams to the operating system I/O streams 0-2 using POSIX dup2() API. In becomes stdin. Out becomes stdout. If Error equals Out an unbuffered stream is associated to the same destination and linked to stderr. Otherwise Error is used for stderr. Output buffering for Out is set to line and buffering on Error is disabled. The operating system I/O streams are shared across all threads. The three streams must be related to a file descriptor or a domain_error file_stream is raised. See also stream_property/2, property file_no(Fd).

Where set_prolog_IO/3 rebinds the Prolog streams user_input, user_output and user_error for a specific thread providing a private interactive session, set_system_IO/3 rebinds the shared console I/O and also captures Prolog kernel events (e.g., low-level debug messages, unexpected events) as well as messages from foreign libraries that are directly written to stdout or stderr.

This predicate is intended to capture all output in situations where standard I/O is normally lost, such as when Prolog is running as a service on Windows.