Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

C code that emulates the pipe command

Status
Not open for further replies.

xchen123

Technical User
Jun 19, 2003
3
US
Anyone have code that emulates the pipe command?

Ex. pipeit <arg1> <arg2>
 
Parallel execution of two commands needs syncronization of output of first command to the input of the second. Writing such code won't be too easy.

There is a in-built C function system() which can execute shell commands from within the C code. You can pass your arguments to this function with a pipe..

Syntax : system(char *Command);

cheers
ashish
 
> Anyone have code that emulates the pipe command?
Which operating system and compiler do you have?
 
I don't think you're going to be able to do this
portably either. Reading the output from the command
into a file and then rereading it in another exec'd
programs stdin is lousy.
Just my opinion trying this with ansi C.








 
The system calls (section 2 of the manual pages) you will find interesting are
fork()
pipe()
dup2()
open()
close()
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top