LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-04-2008, 03:55 AM   #1
john.daker
Member
 
Registered: Jul 2008
Posts: 33

Rep: Reputation: 15
How to redirect the stdin and stdout of child process which exec interactive prog?


Hi all

I have a program which has four processes:
father process: get the standard input from user
child process 1: exec `bc`(for example)
child process 2: exec `ftp`
child process 3: exec `ssh`

How can I send the input from father process to all the three processes as their stdin , and got the output of the 3 processes return to father process rather then print to stdout?

Thanks
 
Old 11-04-2008, 09:27 AM   #2
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
You need to use pipe and dup2. pipe will create a set of pipe descriptors and dup2 can move those over old file descriptors, in this case being standard input and standard output.
ta0kira
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to redirect standard stdout to multi stdout ( Bash )? john.daker Programming 4 11-04-2008 12:20 AM
[C] stdout and stdin replace by pipes and execve the child chudzielec Programming 6 01-27-2008 06:52 AM
How to capture both stdin and stdout of a child process? jineshkj Linux - Software 2 04-21-2006 07:34 AM
redirect stdin/stdout of running process xtravar Linux - Software 3 03-06-2004 08:54 PM
writing to child process stdin avikosan Programming 2 11-11-2003 08:06 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:22 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration