Hi,
I have two processes (one written in tcl (wish process) and the other is a C Program (a.out))
I am opening the second process as a sub process from wish process by using pipe as follows
set pipe [open "| sh -c { $execCommand } " r+ ]
So, when i want to send a message to process 2, i can use "puts $pipe <message>" and the message can be received at process2 at fd 0 . i.e., "read(0,buff,size) in process2"
Now my query is "How to change that default fd 0 at receiving side? i.e., I want to receive the message when I give read((5,buff,size)) on process2???"
Thanks in Advance,
rAzoRbaCK
1 reply to this topic
#1
Posted 06 May 2011 - 04:22 AM
|
|
|
#2
Posted 06 May 2011 - 12:10 PM
You need to use (in linux c)
It basically copies param1 descriptors into param2 after closing the param2 from file descriptor table if opened previously.
So something like
would do the job
#include <unistd.h> int dup2(int fildes, int fildes2);
It basically copies param1 descriptors into param2 after closing the param2 from file descriptor table if opened previously.
So something like
if (dup2(your_fildes, STDIN_FILENO) == -1) {
printf("Failed to redirect standard input");
}
would do the job
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account

Back to top









