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
Solved

Pipe

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

ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
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 conditional statements in the C programming language.

789 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