.. index:: single: process
.. _process/0:

.. rst-class:: right

**object**

``process``
===========

Portable process handling predicates.

| **Availability:** 
|    ``logtalk_load(process(loader))``

| **Author:** Paulo Moura
| **Version:** 2:4:0
| **Date:** 2026-11-12

| **Compilation flags:**
|    ``static, context_switching_calls``


| **Dependencies:**
|   (none)


| **Remarks:**

   - Supported backend Prolog systems: ECLiPSe, GNU Prolog, SICStus Prolog, Shumway Prolog, SWI-Prolog, Trealla Prolog, and XVM.
   - Option ``type/1`` limitation: This option is ignored on ECLiPSe, GNU Prolog, and XVM.

| **Inherited public predicates:**
|    (none)

.. contents::
   :local:
   :backlinks: top

Public predicates
-----------------

.. index:: create/3
.. _process/0::create/3:

``create/3``
^^^^^^^^^^^^

Creates a new process from the given executable and list of arguments. Supported options are ``process(Pid)``, ``stdin(Stream)``, ``stdout(Stream)``, ``stderr(Stream)``, and ``type(Type)``.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``create(Executable,Arguments,Options)``
| **Mode and number of proofs:**
|    ``create(+atom,+list(atom),+list(compound))`` - ``zero_or_one``


------------

.. index:: wait/2
.. _process/0::wait/2:

``wait/2``
^^^^^^^^^^

Waits for a process to terminate and retrieves its exit status. The value of ``Status`` depends on the backend. For a successfully terminated process, ``Status`` is either ``0`` or ``exit(0)``.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``wait(Pid,Status)``
| **Mode and number of proofs:**
|    ``wait(+integer,-integer_or_compound)`` - ``one``


------------

.. index:: wait/3
.. _process/0::wait/3:

``wait/3``
^^^^^^^^^^

Waits once for a process to terminate, returning the backend-specific status in ``RawStatus`` and its normalized form in ``NormalizedStatus``.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``wait(Pid,RawStatus,NormalizedStatus)``
| **Mode and number of proofs:**
|    ``wait(+integer,-integer_or_compound,-compound)`` - ``one``

| **Remarks:**

    - Normalized status: Either ``exit(Code)``, ``killed(Signal)``, or ``unknown(RawStatus)`` when native information is insufficient.
    - GNU Prolog limitation: No distinction between processes that exited on their own with non-zero status and processes that were killed.


------------

.. index:: kill/2
.. _process/0::kill/2:

``kill/2``
^^^^^^^^^^

Kills the given process with the specified signal (an integer or one of the following atoms: ``sighup``, ``sigint``, ``sigkill``, or ``sigterm``).

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``kill(Pid,Signal)``
| **Mode and number of proofs:**
|    ``kill(+integer,+atom_or_integer)`` - ``zero_or_one``


------------

.. index:: kill/1
.. _process/0::kill/1:

``kill/1``
^^^^^^^^^^

Kills the given process using the default signal (``sigkill``).

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``kill(Pid)``
| **Mode and number of proofs:**
|    ``kill(+integer)`` - ``zero_or_one``


------------

Protected predicates
--------------------

(none)

Private predicates
------------------

(none)

Operators
---------

(none)

.. seealso::

   :ref:`os <os/0>`

