Solved

Pipe

Posted on 2001-06-21
1
461 Views
Last Modified: 2006-11-17
I have a Socket Server program which uses anonymous pipe to execute a command and get the results into a buffer. I followed these steps

Create anonymous pipe, Attach pipe's write end to the STDOUT.
Call system("command"),
Close write end of the pipe
Read from the pipe's read end
Close the read end of the pipe.

My problem is , every time I read from the pipe the previous output is still there. Say first time I have 100 bytes o/p, second time 30 bytes o/p. But when I read second time still I get 100 bytes (30 new + 70 old) I tried using FlushFileBuffers(), but no imporovements.

Instead of pipe I tried using _popen() function. It works fine, but it only gives me the STDOUT values to the buffer. But I also need the STDERR values if the command execution failed. But in pipes I use two pipes, one for STDOUT another for STDERR.

Could you please help me?  
Thanks in advance!
0
Comment
Question by:bkm
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 86

Accepted Solution

by:
jkr earned 75 total points
ID: 6215078
Try to use the following command line with '_popen()':

command.com /c <your command> 2>&1

The last statement merges STDOUT with STDERR
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question