Home » Extra libraries, Code snippets, applications etc. » C++ language problems and code snippets » capturing stdout/err/in of subprocess
Re: capturing stdout/err/in of subprocess [message #1743 is a reply to message #1717] |
Fri, 17 March 2006 10:52 |
mr_ped
Messages: 825 Registered: November 2005 Location: Czech Republic - Praha
|
Experienced Contributor |
|
|
I don't see problem with knowing if the subprocess is looking for input.
If it does, it must call "getchar()" and similar things, i.e. listen to the standart input. If you (as an console) own the standart input line, you will know when the subprocess listens to it, so you know when to echo the input.
I.e.
OS input -> your console listen to it, and fetch the input into internal buffer, which will be standart input for subprocess -> subprocess connected to input from your console.
I don't know how this should be done in C++ and Windows, but that's imho the proper model how it should be done.
The cmd.exe allows you to choose the input for the subprocess, so you can run the subprocess and feed him with input from file or from output from other process trough pipe, and the reason why it works is because it knows when the subprocess calls getchar(), so the whole file is not feeded to the subprocess right at the start, but it's sended char by char whenever subprocess asks for next one.
(actually having ability to redirect input/output is very important in unix world, as most of the standart tools are highly specialized, and to fullfill your task you need usually to chain several tools to produce the final result, like "ps | grep gcc" to see only gcc processes. So the "ps" tool does not need to contain some "filter" code, as the filter code is included in grep, etc...
|
|
|
|
|
capturing stdout/err/in of subprocess
By: wilho on Mon, 13 March 2006 14:21
|
|
|
Re: capturing stdout/err/in of subprocess
By: mirek on Mon, 13 March 2006 14:50
|
|
|
Re: capturing stdout/err/in of subprocess
|
|
|
Re: capturing stdout/err/in of subprocess
By: mirek on Tue, 14 March 2006 09:22
|
|
|
Re: capturing stdout/err/in of subprocess
By: wilho on Tue, 14 March 2006 08:53
|
|
|
Re: capturing stdout/err/in of subprocess
|
|
|
Re: capturing stdout/err/in of subprocess
By: mirek on Tue, 14 March 2006 10:54
|
|
|
Re: capturing stdout/err/in of subprocess
|
|
|
Re: capturing stdout/err/in of subprocess
By: lundman on Tue, 14 March 2006 12:00
|
|
|
Re: capturing stdout/err/in of subprocess
By: mirek on Tue, 14 March 2006 12:04
|
|
|
Re: capturing stdout/err/in of subprocess
|
|
|
Re: capturing stdout/err/in of subprocess
By: mirek on Wed, 15 March 2006 09:59
|
|
|
Re: capturing stdout/err/in of subprocess
By: mr_ped on Fri, 17 March 2006 10:52
|
|
|
Re: capturing stdout/err/in of subprocess
By: mirek on Fri, 17 March 2006 12:08
|
|
|
Re: capturing stdout/err/in of subprocess
By: fudadmin on Fri, 17 March 2006 12:11
|
|
|
Re: capturing stdout/err/in of subprocess
By: mirek on Fri, 17 March 2006 12:23
|
|
|
Re: capturing stdout/err/in of subprocess
|
|
|
Re: capturing stdout/err/in of subprocess
By: mirek on Fri, 17 March 2006 23:25
|
|
|
Re: capturing stdout/err/in of subprocess
|
|
|
Re: capturing stdout/err/in of subprocess
By: lundman on Sat, 18 March 2006 01:01
|
|
|
Re: capturing stdout/err/in of subprocess
By: mirek on Sat, 18 March 2006 08:47
|
|
|
Re: capturing stdout/err/in of subprocess
By: wilho on Sat, 18 March 2006 14:33
|
|
|
Re: capturing stdout/err/in of subprocess
By: lundman on Sat, 18 March 2006 15:05
|
Goto Forum:
Current Time: Sat Sep 21 03:09:11 CEST 2024
Total time taken to generate the page: 0.06214 seconds
|