Coder Social home page Coder Social logo

lua-spawn's Introduction

A lua library to spawn programs

Status

Build Status

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

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. 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 doesn't allow interaction with any file descriptors
  • 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 family of functions.

lua-spawn's People

Contributors

daurnimator avatar ghedo avatar hishamhm avatar siffiejoe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

lua-spawn's Issues

Return pid from waitpid

Currently returns true/nil,what,code which doesn't include the pid we just got the code of.

Support SETSID

Now approved by POSIX.

Available in recent glibc and musl

Builds on OSX fail because scheduling affinity flags are not supported.

On this platform, the definitions of POSIX_SPAWN_SETSCHEDPARAM are commented out in spawn.h, so luarocks make fails with the following errors:

spawn/posix.c:185:29: error: use of undeclared identifier 'POSIX_SPAWN_SETSCHEDPARAM'
        lua_pushboolean(L, flags & POSIX_SPAWN_SETSCHEDPARAM);
                                   ^
spawn/posix.c:187:29: error: use of undeclared identifier 'POSIX_SPAWN_SETSCHEDULER'
        lua_pushboolean(L, flags & POSIX_SPAWN_SETSCHEDULER);
                                   ^
spawn/posix.c:210:37: error: use of undeclared identifier 'POSIX_SPAWN_SETSCHEDPARAM'
        if (lua_toboolean(L, -1)) flags |= POSIX_SPAWN_SETSCHEDPARAM;
                                           ^
spawn/posix.c:212:37: error: use of undeclared identifier 'POSIX_SPAWN_SETSCHEDULER'
        if (lua_toboolean(L, -1)) flags |= POSIX_SPAWN_SETSCHEDULER;
                                           ^
spawn/posix.c:261:16: warning: implicit declaration of function 'posix_spawnattr_getschedpolicy' is invalid in C99 [-Wimplicit-function-declaration]
        if (0 != (r = posix_spawnattr_getschedpolicy(attr, &schedpolicy))) {
                      ^
spawn/posix.c:275:16: warning: implicit declaration of function 'posix_spawnattr_setschedpolicy' is invalid in C99 [-Wimplicit-function-declaration]
        if (0 != (r = posix_spawnattr_setschedpolicy(attr, schedpolicy))) {
                      ^
2 warnings and 4 errors generated.

Error: Build error: Failed compiling object spawn/posix.o
env MACOSX_DEPLOYMENT_TARGET=10.8 gcc -O2 -fPIC -I/Users/michael/local/torch/install/include -c spawn/kill.c -o spawn/kill.o -D_POSIX_C_SOURCE=1 -Ivendor/compat-5.3/c-api/
env MACOSX_DEPLOYMENT_TARGET=10.8 gcc -O2 -fPIC -I/Users/michael/local/torch/install/include -c spawn/posix.c -o spawn/posix.o -D_POSIX_C_SOURCE=1 -Ivendor/compat-5.3/c-api/

Add Makefile?

The only supported install method is currently luarocks. Do we want to support a traditional makefile?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.