[Mono-list] using pipes with mono
Chris Howie
cdhowie at gmail.com
Sun Aug 23 17:00:40 EDT 2009
On Sat, Aug 8, 2009 at 8:14 AM, raduM<radu_marg at yahoo.com> wrote:
> I am trying to use unamed pipes to communicate between a gui written with
> GTK# and a C program. I run the following on the C# side:
>
> int [] pipe_fds = new int[2];
> Syscall.pipe (pipe_fds);
> string arguments = pipe_fds[0] + "-" + pipe_fds[1]
> Process.Start("myexe", arguments);
>
> And than on the C side:
>
> int pipe_fds[2] = {0, 0};
> // .. parse argv, get file descriptors
> FILE* pipe_stream = 0;
> pipe_stream = fdopen (pipe_fds[1], "w");
>
> The moment the last line is executed, my program crashes. In the debugger,
> mdb shows:
> Thread @1 received signal 15 at #0
>
> I do not understand what am I doing wrong?
To my knowledge, this is not how unnamed pipes work. Each process has
its own "namespace" of FDs, and passing FDs from one process to
another process is not going to work. The way you'd do this in C
would be to create the FDs then fork(), which duplicates FDs to the
new process.
Why can you not just use stdout/stdin to do what you want?
--
Chris Howie
http://www.chrishowie.com
http://en.wikipedia.org/wiki/User:Crazycomputers
More information about the Mono-list
mailing list