Please have a look at the requirement.
How to open a new file descriptor in Read/Write mode without
binding with an object like file, STDIN . etc .,?
We have a API call that creates a new Process in it? To capture
all the streams of the new process. We pass the fd to library
which in turn does the dup2 operation. It collects only one file
descriptor as a Parameter and it does dup2 to all 3 streams(IN, OUT, ERR).
I'll use the same descriptor to communicate with the new Process.
To achieve this i did "pipe" and i sent the fd (i.e., for writing) as the
But it is failing to use the same file descriptor for read.
I think we can achieve this if we create a new file descriptor in read write
mode with out binding with any object.
If U have any way of implementing this. pls let us know
Pinned topic Create new FD for read & write
Answered question This question has been answered.
Unanswered question This question has not been answered yet.
Updated on 2002-09-29T21:08:51Z at 2002-09-29T21:08:51Z by SystemAdmin
SystemAdmin 110000D4XK2364 Posts
RE: Create new FD for read & write2002-09-29T21:08:51ZThis is the accepted answer. This is the accepted answer.I'm not sure if you're having trouble with the pipe or with the fd you want to
pass, but I suspect the pipe. Many pipe imnplementations are half duplex and a
programmier assuming this leads to more portable code. The pipe() call returns
two file descriptors, one for writing and one for reading. If a process then
does a fork() to create a child the parent will typically close the read end of
the pipe while the child will close the write end of the pipe and this makes an
IPC channel from parent to child. If you want a return path, you should call
pipe() twice before calling fork(). In this case the parent closes the write
end of the second pipe and the child closes the read end and the second pipe
can then be used to communicate back to the parent from the child.
Once you have the pipes you can pass open file descriptors. The book "Advanced
Programming in the UNIX Environment" by W. Richard Stevens has a couple of
chapters on interprocess communications that describe this process quite well.
You can also check the pipe() syntax on Linux using info pipe.Updated on 2002-09-29T21:08:51Z at 2002-09-29T21:08:51Z by SystemAdmin