Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 24-04-2009
Member
 
Join Date: Apr 2009
Posts: 107
[Named Pipe] Redirection of STDIN and STDOUT

Hello,

Before I make this code and after some searching, I wanted to know if it is possible to redirect STDOUT and SDTIN to "Named Pipes" which was created by another process.

The goal is to quickly change the code of a console application that interacts with the user. Check it to launch if the "named piped exists, if so, it redefines the standard flow, otherwise we keep the default ones.

Apparently, I would have to turn to the dup () but I am pissed off is that it takes an integer parameter and CreateNamedPipe () returns a handle ... So I think that this will not work, I am wrong?

Is this possible and if this is true, how do I do to achieve it "simply" because I want to avoid setting a mechanism for ReadFile () and WriteFile (), unless I have the choice ...

NB: The choice of "pipe" is a design choice because I also used when creating another process using CreateProcess ().
Reply With Quote
  #2  
Old 24-04-2009
Member
 
Join Date: Oct 2008
Posts: 167
Re: [Named Pipe] Redirection of STDIN and STDOUT

Quote:
I wanted to know if it is possible to redirect STDOUT and STDIN to "Named Pipes" which was created by another process.
If your named pipes exist, why use CreateNamedPipe ()?
As for your function dup (), I do not know what it is.

However, if you wish to obtain a handle to your pipe, you have to CreateFile (), as often elsewhere. You can also use CallNamedPipe () that combines several functions, including the previous one, to establish an easy interaction with your named pipes.

Finally, with regard to the redirection, you must turn to SetStdHandle () which handles the input and output (STD_OUTPUT_HANDLE. ..) are substituted by those tubes.

That is quite a summary of the thing that will allow you to move forward.
Reply With Quote
  #3  
Old 24-04-2009
Member
 
Join Date: Apr 2009
Posts: 107
Re: [Named Pipe] Redirection of STDIN and STDOUT

Quote:
If your named pipes exist, why use CreateNamedPipe ()?
I'm can not be expressed, I said that another process has created the previously named pipes.

Quote:
Finally, with regard to the redirection, you must turn to SetStdHandle () which handles the input and output (STD_OUTPUT_HANDLE. ..) are substituted by those tubes.
Ah, here is what I missed.

I use the IDE Code: Blocks and MinGW as compiler.
Thank you!
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "[Named Pipe] Redirection of STDIN and STDOUT"
Thread Thread Starter Forum Replies Last Post
stdin:error0? What is this? NewComer Operating Systems 3 24-04-2010 10:56 PM
Inter-thread communication with stdout Captain Carrot Software Development 5 12-03-2010 12:34 PM
How to use pipe between programs in C? Harpreet Gaur Software Development 5 08-01-2010 10:13 AM
USB:Pipe not Opening! sunwins Software Development 2 27-05-2009 08:33 AM
How can I Redirect stderr into stdout ? TALA Software Development 4 27-02-2009 08:28 PM


All times are GMT +5.5. The time now is 01:22 AM.