EOF to stdin when launching process asynchronously on macOS
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 38/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- cpp
- Domain
- operating-systems
Research direction
Start by compiling and running the supplied C++ reproducer on macOS 15.6.1 with Boost 1.89.0; trigger r and observe std::cin after /bin/ls exits. Inspect the interaction between bp::process_stdio{nullptr}, asynchronous launch, and the parent stdin state. Done means subprocess completion no longer causes the input loop to see EOF while the reproducer still reports the child exit code.
Written by the indexing model from the issue text.
Description
On macOS 15.6.1 M3 the program below exits due to EOF flag being raised on std::cin after subprocess finishes.
#include <boost/process.hpp>
#include <boost/asio.hpp>
#include <cstdio>
#include <string>
#include <iostream>
#include <future>
#include <vector>
namespace asio = boost::asio;
namespace bp = boost::process::v2;
void runCommand(const std::string &cmd);
int main(int argc, char *argv[]) {
std::vector<std::future<void>> tasks;
std::string line;
while(true) {
if (!std::getline(std::cin, line)) {
if (std::cin.eof()) {
break;
}
std::printf("Error reading input?\n");
std::cin.clear();
continue;
}
if (line == "r") {
tasks.push_back(std::async(std::launch::async, []() {
runCommand("/bin/ls");
}));
}
}
return 0;
}
void runCommand(const std::string &cmd) {
try {
std::printf("Running subprocess: %s\n", cmd.c_str());
asio::io_context ctx;
bp::process subProcess(ctx, cmd, {}, bp::process_stdio{nullptr});
subProcess.wait();
std::printf("Finished running subprocess with exit code %d\n", subProcess.exit_code());
} catch (const std::exception &ex) {
std::printf("Error running subprocess: %s\n", ex.what());
}
}
Compiler
Apple clang version 17.0.0 (clang-1700.0.13.5)
Target: arm64-apple-darwin24.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
Boos version (from vcpkg)
1.89.0
Example run:
boost-process git:(cpp-boost-process) ✗ ./build/main
r
Running subprocess: /bin/ls
CMakeLists.txt README.md build main.cpp vcpkg.json vcpkg_installed
Finished running subprocess with exit code 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 ·