Giter Site home page Giter Site logo

sockproc's Introduction

Introduction

Sockproc daemon is a simple server for executing shell commands or processes. It can be useful in the situations, where a typical system call to launch a child process and wait for its completion is unacceptable, due to its blocking nature. Instead, a socket can be opened to sockproc, a command written to it, and then once child process completes, its exit code, output stream data and error stream data can be read back from the socket.

Example

Launch sockproc on a UNIX domain socket:

$ ./sockproc /tmp/shell.sock
$ chmod 666 /tmp/shell.sock

Connect to socket and type in a command line to execute, followed by a line that contains the number 0:

$ telnet /tmp/shell.sock
Trying /tmp/shell.sock...
Connected to (null).
Escape character is '^]'.
find /usr/local/include | grep lua
0
status:0
109
/usr/local/include/lua.h
/usr/local/include/lua.hpp
/usr/local/include/luaconf.h
/usr/local/include/lualib.h
0
Connection closed by foreign host.

Execute a bad command:

$ telnet /tmp/shell.sock
Trying /tmp/shell.sock...
Connected to (null).
Escape character is '^]'.
foobar
0
status:32512
0
37
/bin/bash: foobar: command not found
Connection closed by foreign host.

Wire protocol

The protocol is very simple, similar somewhat to HTTP:

Request format:

<command-line>\r\n
<stdin-byte-count>\r\n
<stdin-data>

Response format:

status:<process-exit-code>\r\n
<stdout-byte-count>\r\n
<stdout-data>
<stderr-byte-count>\r\n
<stderr-data>

License

The MIT License (MIT)

sockproc's People

Contributors

fieldsye avatar irr avatar juce avatar

Watchers

 avatar  avatar

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.