Capture output of a continuously running child process?
⚓ Rust 📅 2026-01-28 👤 surdeus 👁️ 10Hey everyone,
I have a proxy binary that I run external to Rust. Once it's up and running, I pipe web requests through it so the binary never closes while my rust program is open. I want to start the binary from within my Rust application but since it takes a few seconds to spin up, I'm trying to monitor the output. Eventually I want to look for a specific string to come through then move on with the execution of the program.
My first attempt was here: Capturing Child Process Output V1 - Pastebin.com
This successfully spawns the child process but doesn't capture any of the output so I have no way of knowing if it started correctly.
My second attempt, after looking through the forums here, got a little closer: Capturing Child Process Output V2 - Pastebin.com
This one also successfully starts the child process and successfully grabs the output of the child process and looks for a matching string to indicate the proxy started correctly. I think I'm closer with this solution to what I want but I can't get it to exit the .for_each loop in the bufreader. I thought adding return; would do it but that doesn't appear to work in Rust and there doesn't appear to be a break; command either.
Can anyone tell me if I'm on the right track? How would I stop the bufreader operation after I match the string I'm looking for so the program can continue?
3 posts - 2 participants
🏷️ Rust_feed