Process.V2 may block with wrong way use of "process_stdio"
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- cpp
- Domain
- operating-systems
Research direction
Reproduce the Windows example using boost/process.hpp, asio::readable_pipe, and process_stdio, comparing the separately declared pipe with the inline process_stdio construction. Inspect process_io_binding and stdio.hpp first, then verify pipe reads and handle state after the detached Git process exits. Done means the reported blocking behavior is explained and the intended usage or implementation is clarified with a regression test or documentation change.
Written by the indexing model from the issue text.
Description
#define WIN32_LEAN_AND_MEAN
#define BOOST_PROCESS_VERSION 2
#include <boost/process.hpp>
#include <iostream>
#if defined(BOOST_PROCESS_V2_WINDOWS)
#pragma comment(lib,"ntdll.lib")
//for MSVC 143
#if defined(_MT) //MultiThread Static
# if defined(_DEBUG)
# pragma comment(lib,"libboost_process-vc143-mt-sgd-x64-1_87.lib")
# endif
#endif
#endif
using namespace boost;
namespace bp = boost::process::v2;
int main()
{
asio::io_context ctx;
std::string output;
output.resize(1000);
system::error_code ec;
{
//bad way
asio::readable_pipe rp2{ ctx };
//this io must declare inside proc like bp::process proc(ctx,xx,xxx,bp::process_stdio{{...},{...},{..}}}
bp::process_stdio io = bp::process_stdio{ nullptr, rp2, nullptr };
//due to process_io_binding@stdio.hpp hold this pip handle with a unique_ptr,
//this make the life time as long as the var 'proc' bellow
//and cannot clean the handle passed to the child,after CreateProcessW
//thus read_some can't get ERROR_PIPE_BROKEN(because there still have a valid PIPE handle in 'io')
//use SysinternalsSuite/procexp64 FIND->FIND Handle or DLL to search 'asio'
//after child process exit.it should not valid.
bp::process proc(ctx, R"(C:\Program Files\Git\bin\git.exe)", { "-v" }, io);
proc.detach();
while (true)
{
//bad:never revice ERROR_PIPE_BROKEN
auto size = rp2.read_some(asio::buffer(output), ec);
if (ec) break;
std::cout<<output.substr(0, size);
}
std::cout<<"badend\n\n";
}
{
//good way
asio::readable_pipe rp{ ctx };
bp::process proc(ctx, R"(C:\Program Files\Git\bin\git.exe)", { "-v" }, bp::process_stdio{ nullptr, rp, nullptr });
proc.detach();
while (true)
{
auto size = rp.read_some(asio::buffer(output), ec);
if (ec) break;
std::cout<<output.substr(0, size);
}
std::cout<<"goodend\n\n";
}
return 0;
}
- Dominant language
- C++
- Stars
- 145
- Forks
- 151
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from boostorg/process
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
-
Difficulty 1/5 Under an hour Newbie friendliness 68/100
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
All issues in boostorg/process
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
AXERA-TECH/ax-llm#77 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
games-on-whales/wolf#509 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
bug-unconfirmed
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
NVIDIA/cuda-samples#453 ·