Solved

Pipe

Posted on 2001-06-21
1
450 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
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Microsoft vcsetup.exe and vcssetup.exe 8 397
Goodbye, so long 10 91
Directory does exist 19 142
mixing C++ and C code elegantly 10 150
An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

757 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now