Solved

Pipe

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Where is my core dump file in Ubuntu? 12 460
C#, VS15, StructLayout 1 135
IIS Log files on Exchange 2013 server 6 238
Computer slow / BSOD 10 70
Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
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…
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.

740 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