Thanks for your help. That now works fine. The reason I came to the conclusion dup2 was not supported was that I searched inside the files in the header directory for the string dup2 using the Windows search facility naively thinking this would find it. Well it didn't! I must remember to use the search facility in TextPad next time as it finds it no problem. Sorry about that!
Richard.
At 00:48 19/02/05, you wrote:
Richard Gipps writes: > I am using the MinGW port of GCC and this doesn't seem to support > dup2().
Sure it does. (dup2() is in the C library, MSVCRT.DLL, the compiler doesn't have much to do with supporting it, except that the headers for the C library, and import libraries, are bundled with it.) dup2() is declared in the <io.h> header. Do you actually get link errors that it isn't found?
> Tor which port of the GCC compiler are you using?
MinGW.
> fd = open ("error.log", O_WRONLY);
Hmm, one needs to use O_CREAT, too, and maybe O_TRUNC. (Hey, that was just a code snippet typed in without testing. Yes, I know one shouldn't do that. Note to self: always provide complete, tested, code snippets. Sigh.)
I now checked whether the below complete program actually works, and yes it does. Error checking obviously still is missing, so if the open() or dup2() fail for some reason, it will silently fail to work as expected.
#include <glib.h> #include <io.h> #include <fcntl.h>
int main (int argc, char **argv) { int fd = open ("stdout.log", O_CREAT|O_WRONLY|O_TRUNC, 0666); dup2 (fd, 2); g_message ("blah\n");
return 0; }
--tml
_______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list