JeffFlinn / boost-process

proposed portable process library for boost
27 stars 4 forks source link

Are there any examples #1

Open dirvine opened 12 years ago

dirvine commented 12 years ago

Hi, a brave library to implement, good luck with it, we need it in boost.

I am looking for such a lib but found what must be a different version that did have examples, most of which appear to have some issues. Is this lib active ? and are there examples ?

JeffFlinn commented 12 years ago

Hello,

Yes, I'm working on the lib as time permits. As you say, doing a portable process library properly is difficult primarily due to the posix side of things with all it's limitations on legal code between fork/exec. I'm digesting a recent thread on the unix newsgroup.

There were several versions and attempts at a boost process library in the past. Mine on github was presented at boostcon 2011 in an attempt to address many of the issues raised.

If you provide a command line that you would like to see implemented using the latest boost process, I can give you the appropriate code to accomplish the same. In the meantime, I'll try to further flesh out docs.

Thanks, Jeff

On Thu, Jun 14, 2012 at 5:38 PM, dirvine < reply@reply.github.com

wrote:

Hi, a brave library to implement, good luck with it, we need it in boost.

I am looking for such a lib but found what must be a different version that did have examples, most of which appear to have some issues. Is this lib active ? and are there examples ?


Reply to this email directly or view it on GitHub: https://github.com/JeffFlinn/boost-process/issues/1

dirvine commented 12 years ago

Hi Jeff, many thanks for the reply. What I am trying to accomplish basically is a small utility that starts and runs some children and optionally restarts these on failure (or non zero return). I knocked together a small example in this gist https://gist.github.com/2948621

This works to an extent but

The problem is 1: wait is blocking (ok workaround with wait on a thread) 2: Child has no default ctr (so cannot be used as a type in a struct, I hacked the child.hpp a wee bit to achieve this) 3: In the gist you will see in the following I tried to create a child and copy it to a struct and then run a thread that waits on the child (it's a little convoluted). If I then try to terminate the child all sorts of bad things happen (whole program crash).

What I would like 1: Be able to watch processes in a better async way if possible (but happy enough to stick with threads if need be) 2: Be able to terminate a child (even forcefully if necessary)

I hope this helps a little and again great work!! I would love to have time to help you, but at least we can check code on several platforms and compilers of that helps

void ProcessManager::RunProcess(int32t id) { auto i = FindProcess(id); if (i == processes.end()) return; bp::context ctx; ctx.environment = bp::self::get_environment(); bp::child c = bp::launch((_i).process.ProcessName(), (_i).process.Args(), ctx); (_i).child = c; c.wait(); if (! (_i).done) RunProcess(id); }