Results 1 to 3 of 3

Thread: [Named Pipe] Redirection of STDIN and STDOUT

  1. #1
    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 ().

  2. #2
    Join Date
    Oct 2008
    Posts
    167

    Re: [Named Pipe] Redirection of STDIN and STDOUT

    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.

  3. #3
    Join Date
    Apr 2009
    Posts
    107

    Re: [Named Pipe] Redirection of STDIN and STDOUT

    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.

    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!

Similar Threads

  1. stdin:error0? What is this?
    By NewComer in forum Operating Systems
    Replies: 3
    Last Post: 24-04-2010, 10:56 PM
  2. Inter-thread communication with stdout
    By Captain Carrot in forum Software Development
    Replies: 5
    Last Post: 12-03-2010, 12:34 PM
  3. How to use pipe between programs in C?
    By Harpreet Gaur in forum Software Development
    Replies: 5
    Last Post: 08-01-2010, 10:13 AM
  4. USB:Pipe not Opening!
    By sunwins in forum Software Development
    Replies: 2
    Last Post: 27-05-2009, 08:33 AM
  5. How can I Redirect stderr into stdout ?
    By TALA in forum Software Development
    Replies: 4
    Last Post: 27-02-2009, 08:28 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,006,752.07598 seconds with 16 queries