mirror of
https://github.com/AdaCore/spawn.git
synced 2026-02-12 13:09:41 -08:00
v23.0.0
On Glib+Windows close pipes and cancel death notification. On non-glib - raise Program_Error if process is running, because the monitor keeps process object references.
Ada Process API (spawn)
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
- Add
with "spawn";orwith "spawn_glib";to your project file. - Create a process object:
P : Spawn.Processes.Process; - Assign program name
P.Set_Program ("/bin/bash"); - (Optional) Assign command line arguments, working directory, environments variables.
- Assign an event listener
P.Set_Listener (L'Unchecked_Access); - Start the process:
P.Start; - (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
Contribute
Feel free to dive in! Open an issue or submit PRs.
License
Description
Languages
Ada
98.8%
C
0.7%
Makefile
0.5%