Hello, I am writing a GTK/GLIB application that will basically act as an interface for existing programs, and I have run into some problems while utilizing the function calls mentioned in the subject field.
My issues are described below, sorry if it is a bit long winded. I don't have experience with using these particular functions so I am not certain what to emphasize. One of the simpler operations the GUI should perform is the following: run a perl script on a file â the output should be handled the following way: *stderr should go to a GtkTextView box *stdout should be input to another external program * stdout from the other external program should be redirected to a file The command line version of said setup would look like this: perlscript.pl âffilename | extprogram > newfile The file (filename) in question is a huge text file (could easily be 300MB+), the perlscript makes some changes in it and extprogram is basically a formatting program that sets record lengths and remove linefeeds. Here is what I do: * create a channel for newfile using g_io_channel_new_file(filename, "w+", NULL) * spawn extprogram using g_spawn_async_with_pipes * create channels for stdin and stdout on extprogram using g_io_channel_unix_new * spawn perlscript.pl using g_spawn_async_with_pipes * create channels for stdout and stderr on perlscript.pl using g_io_channel_unix_new *create watches on stderr and stdout from perlprogram.pl using g_io_add_watch -the stderr watch triggers on G_IO_IN and G_IO_HUP and calls a function that updates the GtkTextViewBox -the stdout watch triggers on G_IO_IN and G_IO_HUP and calls a function that writes to the stdin channel on extprogram *create watch on stdout from the external program using g_io_add_watch -this watch triggers on G_IO_IN and G_IO_HUP and calls a function that writes to the newfile channel Here is the problem: The above scenario almost works. The problem is that the last part of the modified file is never written to newfile. If I look at the buffers in the function that writes to stdin on the external program everything is there, right up until the end of the file. If I look at the buffers in the function that writes to newfile they will stop a bit before the end of the file. If I look at the actual newfile the content there stops even a bit before the last buffer in the function that writes to newfile. Here is some more information: If I choose to write stdout on extprogram to the same as parents (set stdout to NULL in g_spawn....) everything comes out ok (apart from that I don't want it on that stdout of course) In the function that writes to newfile I read the buffers from the channel for stdout on extfile using g_io_channel_read_chars. I have a check on the return value from this and it never gets to return anything other than G_IO_STATUS_NORMAL. It appears that it suddenly is not called anymore. I have tried putting in all possible flags in the watch function but no luck. I shut down the stdin channel to extprogram when there is no more input. Checking the last buffer written to extprogram reveals that this is the correct one, but this then seem to never reach stdout on extprogram, or if it does it appears that it does not trigger the watch function that calls the write to newfile function. rgds, Ole C. _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list