[process] working directory issue

I'm attempting to use boost::process to launch a command line tool called "catdoc.exe." Catdoc takes one argument (the path to a word document). Catdoc will then extract the text from the doc file and output it via standard error to the command line which I've redirected into a string below. So far everything works with the below code except instead of getting the text out of "a.doc" I get an error saying "catdoc cannot find codepage 1251" these codepages are saved in a directory called "charsets" which is saved in the same place catdoc.exe. The problem, I believe, is that the working directory is not set as Catdoc works fine (and finds the codepages) when I execute it manually from the command line, outside of my C++ code. My two questions are as follows: 1. Is there a way to set the working directory (and if so, will this fix my problem)? 2. Is there a way to set a time-out on the underlying process (ie. kill the process if it becomes unresponsive)? Thanks in advance for your help! My Code: using namespace boost; process::child start_child() { string exec = "catdoc.exe"; std::vector<std::string> args; args.push_back("C:\\a.doc"); process::context ctx; ctx.stderr_behavior = process::capture_stream(); return process::launch(exec, args, ctx); } string ExtractText() { string rawtext = ""; process::child c = start_child(); process::pistream &is = c.get_stderr(); std::string line; while (std::getline(is, line)) rawtext += line; return rawtext; } v/r -Keith

On Tue, 15 May 2012 09:08:29 -0600, Bertolino, Keith D. <KBertolino@ciphertechsolutions.com> wrote: Keith,
I'm attempting to use boost::process to launch a command line tool
I'm not entirely sure which Boost.Process draft you use and where you got it from. So maybe my answers don't make sense for the version you use.
[...]1. Is there a way to set the working directory (and if so, will this fix my problem)?
process::context should have a member variable called work_dir (a std::string).
2. Is there a way to set a time-out on the underlying process (ie. kill the process if it becomes unresponsive)?
Boost.Asio 1.49 has a signal_set and a windows::object_handle which you could use to asynchronously wait for a child process to exit. If your handlers aren't called in time you could kill the child process. Boris
[...]
participants (2)
-
Bertolino, Keith D.
-
Boris Schaeling