Add-Ons & Services

How to detect when a Poco sub Process crashes?

Please post support and help requests here.
Posts: 2
Joined: 23 Jul 2012, 18:50

How to detect when a Poco sub Process crashes?

Postby pbaumer » 26 Jul 2012, 14:03

I am using Poco to create a process in my app. I would like to relaunch the process if the process exits gracefully or it crashes.

Currently it is started as follows:

Code: Select all

ProcessHandle ph = Process::launch( "foo.exe", args, 0, &outPipe, 0);
PipeInputStream istr(outPipe);
std::string s;
int c = istr.get();
while (c != -1)
    s += (char) c; c = istr.get();

Graceful exit is handled easily by waiting for the output pile to end as shown above.

How can I handle when the process crashes? I need to handle this on Windows and Linux.

Posts: 89
Joined: 08 Nov 2010, 17:29

Re: How to detect when a Poco sub Process crashes?

Postby marlowabnp » 08 Aug 2012, 10:13

I am also using Poco for process management. I create a thread which launches the process. This child thread communicates with the parent thread using a lightweight message queue. The messages include information that indicates the status of the child, including the exit code from the launched process (obtained via the wait method). If you are interested you can see the code at http://laum.sourceforge.net.

Return to “Support”

Who is online

Users browsing this forum: No registered users and 1 guest