Comments (5)
The exit_code is considered invalid after calling terminate. That was a design decision, because I thought, if you terminate the thing, you don't really care about the exit-code; I actually can set it on windows. I would however not use an arbitrary value, since I cannot set one on posix.
Now I could add that, i.e. capturing the exit_code
, which would make it platform-dependent; i.e. it's not a given my design choice was correct. May I ask do you need that in a real scenario or are you just playing around with the library?
from boost-process.
that's ok, I'm just evaluating the lib. All is fine if it's the design principle.
from boost-process.
Alright then. Well I might get design choices wrong, so if there's a good reason, I'll gladly fix that. Just tell me if you find something.
from boost-process.
I have another suggestion: would if be possible to expand extension's "event" on_... handlers with something like:
on_exit
on_crash
on_terminate
on_<whatever>
It could be done, regarding http://doc.qt.io/qt-5/qprocess.html which is pretty cool API (except mandatory event loop handling)
I'm really picky about APIs, and I can see Qt's QProcess very easy to use. On the other side your api offer almost the same comfort, I'm just missing enhanced status reports.
Just suggesting things from my perspective, no offense here ;)
My long-term usecase is to launch N processes. These processes have to be monitored for their status. Ideally to relaunch on child process crash. So it's up to me now how to get this status.
Please, don't take it as an offense. Boost::process is great lib {ok, I'm not c++ guy, so it forces me to read all src code if I need to do basic things, thats my problem ;)) and it's very easy to use. I just need some "extended" things.
from boost-process.
No problem I'm open to suggestions. One upside to boost.process for you could be that it has an interface for extensions. This also means that you can develop an extension and if you then ask me to add it, it gets much more likel.
I'm not sure where you see the events (i.e. signals) in QProcess but alright, let me explain my rationale: this library doesn't aim to be the perfect process library ,but to provide a thin layer for portability. Thus things that are not solvable in a portable way are not in. And also a custom handler for SIGCHLD
wouldn't be the default.
Thus crash, terminate and are all the same namely exit. The problem is: on crash your exit-code is undefined, on terminate, to some degree, also. So it's not really that easy; now posix has some exit-codes defined, but windows hasn't thus (again) I didn't find a portable solution here.
So that's the problem, if I were to accept the overhead, that's not really possible, since I have to assume behaviour of the child process (i.e. the exit codes), which this library cannot. If you know more (since it's your application) you can implement this rather easily yourself.
The way I would handle that is through the asynchronous wait, let's say you want to use boost.signals2 for that, too. (you can put it into a class too, and I hope it works).
using boost::signals2::signal;
namespace bp = boost::process;
signal<void(int)> on_error;
signal<void()> on_failure;
signal<void()> on_success;
boost::asio::io_service ios;
child c("foo", on_exit=[&](int code, const std::system_error &)
{
if (code == 0)
on_success();
else if (code == 1); //regular error, THIS IS AN ASSUMPTION about the child process
on_failure();
else
on_error(code);
});
ios.run();
Btw. if you need some help to get started with process or asio, you can just write me an E-Mail.
from boost-process.
Related Issues (20)
- file descriptor leak on linux HOT 2
- avoid crash on linux HOT 1
- Typo in doc: boost-process/doc/concepts.qbk
- Extra warnings on MSVC 2019 HOT 1
- Enable ability to set the job object to kill children processes if the parent dies HOT 4
- Linux: on_exit error when using synchronous calls HOT 3
- _env_impl update missing in reload() in native_environment_impl<wchar_t>
- CLang in Windows reports non-void function does not return a value HOT 1
- Zombie process In Boost:: process::wait_until(wait_for_exit.hpp) HOT 6
- opstream::close() does not close the underlying pipe as I would have expected HOT 1
- wait_for waits until timeout if there is a second child process HOT 1
- two children with closed pipes hang causes wait_for to timeout and return false HOT 1
- [question] will this resolve ASIO not safe when call fork issue? HOT 3
- Group wait does not wait for demonized processes on Linux HOT 1
- Win32: Incorrect handling of GetEnvironmentVariable return value HOT 1
- env.hpp is not standalone HOT 1
- Compilation fails with '/permissive-' in Boost 1.75.0 when "boost/process/group.hpp" is included
- How can I read the output of 'socat' command using boost::process::system ? HOT 1
- Pipe_out not implement uses_handles. HOT 1
- Need a way to obtain pid_t of the current process HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from boost-process.