[Mono-list] Problem redirecting stdout

David Morán david.moran.anton at gmail.com
Wed Aug 12 17:07:11 EDT 2009

First of all hello everybody, I'm new in this forum.

I'm a traditional C developer getting his first steps with mono and I need a
little bit of help. I need something very simple but I'm starting to think
is a impossible task with mono and C#, ok, let me explain the problem:

I'm working in a GNU/Linux enviroment and I have a external library
(developed in C) which has a couple of function that return its values using
stdout (yes, I know it, it's a crazy thing, but it works like it works). I
need to parse its output but I don't know what is the method to do this...
In C I'll make something like this:

=== CUT HERE ===
if(fork() == 0) {
   void (*f)(void);
   void *h;
   dup2(p[1], STDOUT_FILENO);
   h = dlopen("libwhatever.so", RTLD_LAZY);
   f = dlsym(h, "f");
read(p[0], buf, SIZE_BUF);
=== CUT HERE ===

In other words, I fork the process and then close stdout and send all output
to a pipe which is read by the parent process, but due to mono doesn't have
fork I don't know how redirect stdout stream to other file stream.

Any idea?

View this message in context: http://www.nabble.com/Problem-redirecting-stdout-tp24943420p24943420.html
Sent from the Mono - General mailing list archive at Nabble.com.

More information about the Mono-list mailing list