Re:

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 05 Jun 2008 10:21:45 +0200 (CEST)
Jean-Philippe Chancelier <jpc@xxxxxxxxxxxxxxx> wrote:

> 
> 
> 	Hi all,
> 	
> 	The link at the end of this mail gives an example of Gtk+
> code that can be used to redirect standard output to a GtkTextView. 
> 	I have changed the original code of Claudio Polegato to 
> 	replace gdk_input_add by g_io_... functions. 
> 
> 	The code seams to work correctly on Linux but 
> 	do not work (blocks) when run on Windows or with Wine 
> 	on Linux. 
> 	Any hints ? 
> 	Best Regards
> 
> 	P.S: code location:
> http://cermics.enpc.fr/~jpc/redirect_stdout_new.c

This is probably because you call g_io_channel_unix_new() instead of
g_io_channel_win32_new_fd() (I do not know either if dup2() or fileno()
work as expected under windows, but they might.)

Apart from that, your code is not safe.  Your callback will block if
exactly 1024 bytes, or an exact multiple of 1024 bytes, are in the pipe
when the callback is invoked until further input is received, which is
almost certainly not what you want.  You should set the non-blocking
flag and then read in the callback until the pipe is empty (or there is
an error/EOF).

Chris 

_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux