https://github.com/daurnimator/lua-spawn
A lua library to spawn programs
https://github.com/daurnimator/lua-spawn
execute lua process run spawn start
Last synced: 8 months ago
JSON representation
A lua library to spawn programs
- Host: GitHub
- URL: https://github.com/daurnimator/lua-spawn
- Owner: daurnimator
- License: mit
- Created: 2015-05-18T05:49:36.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2022-05-12T15:03:50.000Z (over 3 years ago)
- Last Synced: 2025-03-29T02:51:26.886Z (9 months ago)
- Topics: execute, lua, process, run, spawn, start
- Language: C
- Size: 229 KB
- Stars: 27
- Watchers: 3
- Forks: 4
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
A lua library to spawn programs
## Status
[](https://travis-ci.org/daurnimator/lua-spawn)
## Features
- High level functions for common cases
- Bindings to the full `posix_spawn` family of functions
- Compatible with Lua 5.1, 5.2, 5.3 and [LuaJIT](http://luajit.org/)
Currently only works on POSIXy systems, but the high level module should be portable to Windows; someone just needs to put the work in.
## Installation
It's recommended to install lua-spawn by using [luarocks](https://luarocks.org/).
This will automatically install run-time lua dependencies for you.
$ luarocks install spawn
## Rationale
Spawning a new child program from a lua script is surprisingly hard.
Existing solutions:
- [`os.execute`](http://www.lua.org/manual/5.3/manual.html#pdf-os.execute) doesn't allow interaction with any file descriptors
- [`io.popen`](http://www.lua.org/manual/5.3/manual.html#pdf-io.popen) only allows interaction with *one of* `stdin` or `stdout`
- `fork` + `exec` isn't portable to non-MMU or non-unix architectures
This project uses the [`posix_spawn`](http://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawn.html) family of functions.