GithubHelp home page GithubHelp logo

subprocess's Introduction

Subprocess Library for C++

This library offers an intuitive and effective way to interact with subprocesses in C++. It is designed to be straightforward, versatile, and easy to use, so you can control and communicate with subprocesses directly from your C++ application.

Features

  • Start and manage subprocesses from within your application.
  • Interact with the standard input/output/error streams of these processes.
  • Synchronize and wait for subprocesses to finish.
  • Capture and handle exit codes.
  • Support for windows and posix platforms.
  • posix_spawn instead of fork() for performance

Getting Started

To get started with the library, you should first clone the repository:

git clone https://github.com/raxvan/subprocess.git

Usage:

subprocess p;
subprocess::CreateData cd;

cd.make_shell("echo hello");

auto sout = [&](const char* buffer, const std::size_t sz) {
	std::cout << std::string(buffer, sz);
};
auto serr = [&](const char* buffer, const std::size_t sz) {
	std::cerr << std::string(buffer, sz);
};
if(p.start(cd, sout, serr))
{
	//started successfully

	int rc = p.join();
	std::cout << "process terminated with " << rc << std::endl;
}
else
{
	std::cerr << "failed to start process!" << std::endl
}

Implementation: You can either include src/subprocess.cpp in a cpp file or add it to your project

subprocess's People

Contributors

raxvan avatar

Watchers

 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.