Maxim Reznik 30c4c83668 Restructure implementation types/packages hierarchy
* Move `Process_Listener` to a dedicated package.

* Make `Spawn.Processes.Process` as a wrapper for
  `Spawn.Internal.Process` to hide internal details from a user.

* Make `Spawn.Internal.Process` API compatible/equal to
  `Spawn.Processes.Process`. Inherit all implementation from
  `Spawn.Common.Process` and move common trivial functionality
  there.

* Move other logic from Process.Platform packages to corresponding
  `Spawn.Internal` package.

* Move `Spawn.Process.Monitor` to `Spawn.Internal.Monitor`.
2022-12-16 17:36:28 +02:00

Ada Process API (spawn)

Build Alire

This library provides simple API to spawn processes and communicate with them. We provide two implementations of the same API - the integrated into Glib event loop and the independent.

Install

Using alire

Run alr get --build spawn or alr get --build spawn_glib.

Also you can build from the cloned repository directory with

alr build

For spawn_glib do this in packages/glib subdirectory:

cd packages/glib
alr build

Build from sources

Clone repository or unpack source archive, then run

make all install PREFIX=/path/to/install

Usage

  1. Add with "spawn"; or with "spawn_glib"; to your project file.
  2. Create a process object:
    P : Spawn.Processes.Process;
    
  3. Assign program name
    P.Set_Program ("/bin/bash");
    
  4. (Optional) Assign command line arguments, working directory, environments variables.
  5. Assign an event listener
    P.Set_Listener (L'Unchecked_Access);
    
  6. Start the process:
    P.Start;
    
  7. (Glib independent case) With no event loop integration you should drive it by you-self periodically calling
    Spawn.Processes.Monitor_Loop (1);
    

The listener will get these events:

  • Standard_Output_Available
  • Standard_Error_Available
  • Standard_Input_Available
  • Started
  • Finished
  • Error_Occurred
  • Exception_Occurred

See an example in the spawn test

Maintainer

AdaCore

Contribute

Feel free to dive in! Open an issue or submit PRs.

License

Apache-2.0 © AdaCore

Description
No description provided
Readme 494 KiB
Languages
Ada 98.8%
C 0.7%
Makefile 0.5%