Status & Roadmap
Authors & License
Funding Ultimate++
Search on this site
Search in forums

SourceForge.net Logo
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 #1761 is a reply to message #1760] Sat, 18 March 2006 08:47 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13055
Registered: November 2005
Ultimate Member
lundman wrote on Fri, 17 March 2006 19:01

I must agree I am not quite following why you need to know if your pipe-child is listening or not. You'll know if the child has gone away (EPIPE). The whole line buffering and echo is a tty/terminal feature which you can disable with ioctl(), that is quite trivial.

Just to remind: we are trying to create own terminal here.


But if you create pipes to your child you need not worry about linemode/echo as it is direct without the tty/terminal layer.

Yes, that is why we need to implement echo/linemode to get the terminal/console equivalent Wink

I am really not sure how to explain it, but the trouble is that terminal runs in "dialog" mode - child process prints something, then waits for input data, then again prints something, you simply need to know when it waits for input data in order to allow user enter them (I am describing user experience here, not implementation !)

You cannot allow user to enter the data all the time, at least that is not what terminals/consoles do...

Another attempt of explanation: You are implementing the terminal/console. You are executing the child process. User presses some key. How your terminal/console application should react to this event? If you would just echo it at the current output position, your characters would be "inlined" with child process output on the screen. And you need to echo that character somehow as it is terminal responsibility. (Of course, at some moment you will send characters down to the stdin pipe, but that is not what we are solving here).

The moral of the story probably is that you cannot implement the terminal just by redirecting stdin/stdout... (makes sense, curses or Win32 console functions seem to work on another level anyway).

Re: capturing stdout/err/in of subprocess [message #1774 is a reply to message #1761] Sat, 18 March 2006 14:33 Go to previous messageGo to next message
wilho is currently offline  wilho
Messages: 19
Registered: February 2006
Promising Member
Lot's of discussion and information, thanks guys. While consoles don't regularlary allow wirting before they're able to receive doesn't IMO mean that it couldn't do so even though it might be a bit messy. If someone is interest to see the problems involved, here'sa nice sample which spawns cmd and redirects its I/O to itself via anonymous pipes.

Lundman, how do I compile LiON with TheIDE? I had to give the win32 define compiler by switch. It compiles, but I get lots of linking errors. As a matter of fact, if someones knows good article about common linker errors and how to resolve them, I'd be itnterested...

[Updated on: Sat, 18 March 2006 14:34]

Report message to a moderator

Re: capturing stdout/err/in of subprocess [message #1775 is a reply to message #1774] Sat, 18 March 2006 15:05 Go to previous message
lundman is currently offline  lundman
Messages: 175
Registered: March 2006
Location: Tokyo
Experienced Member

You know, I should make a project for TheIDE too.. I just made project files for vc6 and vc8. We just link against the library (and wsock32.lib etc) in TheIDE. I'll work on it.

Previous Topic: New EH handling in MinGW
Next Topic: DLL and U++ type
Goto Forum:

Current Time: Thu Jan 28 02:44:48 CET 2021

Total time taken to generate the page: 0.01410 seconds