Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8392179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:27:10+00:00 2026-06-09T19:27:10+00:00

I have some difficulties getting my pipes work. I have the following code: /*

  • 0

I have some difficulties getting my pipes work. I have the following code:

/* Set security attributes */
sa.nLength = sizeof(SECURITY_ATTRIBUTES);
sa.bInheritHandle = TRUE; 
sa.lpSecurityDescriptor = NULL; 

if (CreatePipe(&Rread, &Rwrite, &sa, 0) == 0 || SetHandleInformation(Rread, HANDLE_FLAG_INHERIT, 0) == 0 || CreatePipe(&Wread, &Wwrite, &sa, 0) == 0 || SetHandleInformation(Wwrite, HANDLE_FLAG_INHERIT, 0) == 0)
{
    /* Error */
}


/* Set process information */
si.dwFlags = STARTF_USESTDHANDLES;
si.hStdOutput = Rwrite;
si.hStdError = Rwrite;


if (CreateProcess(NULL, argsCasted->cmd, NULL, NULL, TRUE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi) == 0)
{
    /* Error */
}


for (;;)
{
    PeekNamedPipe(Rread, NULL, 0, &a, NULL, NULL);

    if (a > 0)
    {
        /* Write output somewhere... */
    }

    if (a == 0 && GetExitCodeProcess(pi.hProcess, &c) != 0 && c != STILL_ACTIVE) break;

    Sleep(50);
}


    /* CloseHandles... */

    /* Free stuff... */

Now when I add si.hStdInput = Wread; (so that I can send input to the process), PeekNamedPipe() blocks.

I simplified the code a lot because it is part of a large multi-threaded application, which is too large to post here. If anyone needs more details from me to solve this problem, please post it here and I’ll add the requested details.

Thanks in advance
Jori.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T19:27:12+00:00Added an answer on June 9, 2026 at 7:27 pm

    PeekNamedPipe will block if there is no data in the pipe to read. You will have to make use of asynchronous/non-blocking I/O.

    Refer : asynchronous IO

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to programing and I have some difficulties getting AlertDialog working. I
I have some difficulties with understanding BindingSource's behaviour. Let's look at following example: Creating
I'm having some difficulties with passing functions around. I have this code: var options
I have a social networking website and I'm getting some difficulties to filter who
I have some difficulties to set up the correct configuration relative to sendAsynchronousRequest:queue:completionHandler: method
I have some difficulties in my project. I got the RGB values from a
I have some difficulties for using Ruby block, passing in a method. As in
I'm have some difficulties here, I am unable to successfully call a method which
I'm having some difficulties with Ajax.BeginForm I have something like this in a view
I have some code on two systems running kernel 2.4.20 and kernel 2.4.38 .

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.