Prev: compilation error when Base Constructor calling pure virtual method
Next: basic_string CoW concurrency: typo in N2668, or very subtle point?
From: Martin B. on 9 Jul 2010 23:12 Hi all! It does happen that I need to start another process and read it's stdout (and stderr) to a buffer to work with that. On Windows, this includes setting up a pipe, calling CreateProcess, reading from the pipe handles, copying to buffer, closing the handles etc. (I do think on posix systems it works about the same with pipe and fork etc.) In Perl (just as an example) all one does is write my $buf = qx/test.exe/; Are there any libraries for C++ that achieve something like this? I'd imagine something like: .... try { wstring buf = subprocess::check_output(L"test.exe"); // Note: Shameless plug from Python :-) } catch(subprocess::CalledProcessError const& e) { wcerr << L"The program returned non zero exit code: " << e.returncode() << endl; } .... cheers, Martin -- [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ]
From: Mathias Gaunard on 11 Jul 2010 04:37
On Jul 10, 3:12 pm, "Martin B." <0xCDCDC...(a)gmx.at> wrote: > Hi all! > > It does happen that I need to start another process and read it's stdout > (and stderr) to a buffer to work with that. > [...] > Are there any libraries for C++ that achieve something like this? There are. There is Boost.Process (not yet a Boost library), Poco and Qt probably have stuff as well. -- [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ] |