e***@gmail.com
2008-05-13 18:20:18 UTC
Hi!
I'm writing a quick little Popen class in C++ on windows. Basically I
want it to:
- Spawn a subprocess
- Upon termination ("Kill"), kill said subprocess, and all children
- Gather stdout/stderr and redirect it to some function I pass in.
I've got this all working, using a mixture of CreateProcess/*JobObject
functions, and the STARTUP_INFO parameters for handle redirection.
My only problem now, seems to be that the pipes seem to get buffered
at around 1024 bytes, at least on my machine, and it tends to give
garbled output if I ever *do* combine the output later on.
I'm curious, is it possible to make the pipe unbuffered (assuming I'm
diagnosing this correctly)?
Looking at the pipe API, it looks like it's not truly possible, since
pipes get a 'suggested' buffer size that the system then does stuff
with anyhow. However, I'm wondering if some underlying implementation
of pipes would solve this (i.e., if I can get a file descriptor from a
pipe and run setvbuf on it, or some such)?
Anyhow, your opinions and knowledge are appreciated. Thanks in
advance!
-e-
I'm writing a quick little Popen class in C++ on windows. Basically I
want it to:
- Spawn a subprocess
- Upon termination ("Kill"), kill said subprocess, and all children
- Gather stdout/stderr and redirect it to some function I pass in.
I've got this all working, using a mixture of CreateProcess/*JobObject
functions, and the STARTUP_INFO parameters for handle redirection.
My only problem now, seems to be that the pipes seem to get buffered
at around 1024 bytes, at least on my machine, and it tends to give
garbled output if I ever *do* combine the output later on.
I'm curious, is it possible to make the pipe unbuffered (assuming I'm
diagnosing this correctly)?
Looking at the pipe API, it looks like it's not truly possible, since
pipes get a 'suggested' buffer size that the system then does stuff
with anyhow. However, I'm wondering if some underlying implementation
of pipes would solve this (i.e., if I can get a file descriptor from a
pipe and run setvbuf on it, or some such)?
Anyhow, your opinions and knowledge are appreciated. Thanks in
advance!
-e-