boost-process | Boost.Process is a library to manage system processes
kandi X-RAY | boost-process Summary
kandi X-RAY | boost-process Summary
This C++11 library is the current result of a long attempt to get a boost.process library, which is going on since 2006.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of boost-process
boost-process Key Features
boost-process Examples and Code Snippets
Community Discussions
Trending Discussions on boost-process
QUESTION
I am writing a C++ program that makes use of named pipes on Windows. I can create and work with them quite fine. The only piece missing to the puzzle is a function to check for a pipe's existence.
Coming from the Unix world I originally tried std::filesystem::exists("\\\\.\\pipe\\myPipe")
but this is not reliable and often errors with ERROR_PIPE_BUSY
.
While searching for an alternative way to check for a pipe's existence, I stumbled upon this issue on GitHub (Boost process) and from there I take it that Boos process circumvents the problem by using a special naming scheme and a counter and then keeping track of that internally (only seems to work for pipes created via Boost process though).
Furthermore according to How can I get a list of all open named pipes in Windows? it seems that there are ways to list the existing named pipes. These solutions are not using C++ though and I did not find a way to port that over.
After having read the documentation of CreateNamedPipe, I now assembled the following solution to my problem:
...ANSWER
Answered 2021-Mar-24 at 18:08std::filesystem::exists("\\\\.\\pipe\\myPipe")
returning ERROR_PIPE_BUSY
means it is using CreateFile()
to actually connect to the pipe. It is not unreasonable for an exists()
implementation to attempt to open the requested file to check its existance.
Per the CreateFile()
documentation:
If there is at least one active pipe instance but there are no available listener pipes on the server, which means all pipe instances are currently connected,
CreateFile
fails withERROR_PIPE_BUSY
.
Which means the pipe does technically exist, it is not ready to receive a new client at that moment.
In the link you provided, many of the solutions provided suggest using .NET's System.IO.Directory.GetFiles()
method to iterate though the contents of "\\.\pipe\"
. This answer shows how that call translates into Win32 API calls using FindFirstFile()
and FindNextFile()
. You can easily do the same API calls in C++, eg:
QUESTION
The following command builds boost using VCPKG.
...ANSWER
Answered 2019-Oct-23 at 01:55It turns out that it is possible to build all of Boost while using ICU for those components that support the ICU feature, as follows.
./vcpkg install boost-locale[icu] boost-regex[icu] boost --triplet x64-windows --recurse
Source: How do I build boost with ICU support without having to build most components of boost twice?
QUESTION
I'm converting some code from using CreateProcess
to use boost-process instead. I need to replace my CreateProcess
usages with boost::process::child
. The problem is they have incompatible ways for me to say "I want to use the default value". What used to be a one line command has become sixteen if
statements.
The function I currently use works like this (simplified):
...ANSWER
Answered 2019-May-29 at 13:34Use a function to create child
objects which contains the branches. Pass std::optional
as parameters:
QUESTION
In the following code, I am trying to implement a program that runs a shell command and get the stdio
, stderr
and return code. I am doing it using boost process
in the async
mode as advised here.
ANSWER
Answered 2018-Oct-03 at 11:41The mistake is indeed very simple: you should cancel the deadline timer!
io_service::run()
will not return unless
- an exception emanated from a handler
- no more work is queued.
While the dead line timer is in progress, that means the second condition isn't met. So io_service::run()
waits for it because you asked it to.
Other notes:
- use the error code to detect timer cancellation instead of racy time comparisons
- no need to loop-chain the timer (in fact, that's asking for bugs where the io_service never completes)
- your code failed to initialize
stopped
andkilled
Live On Coliru
QUESTION
Using the results of this question simultaneous read and write to child's stdio using boost.process, I am trying to modify the code so that a file is read, piped through gzip, the output of gzip piped through bzip2, and finally the output of bzip2 written to a file.
My first attempt was
...ANSWER
Answered 2018-Apr-27 at 22:25I'd write that code simply like:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install boost-process
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page