Re: Using threads ?



Le jeu 20/02/2003 à 18:18, Eric M. Monsler a écrit :
To sum my problem up, I want to :

- exec a binary in the background from my Gtk2 window
- keep an eye on the binary execution's state (running|finished or X %
complete)
- update some widgets according to the state of the binary execution




Not sure that the thread suggestion gives you any feedback other than 
when the application terminated.

Indeed, it will be better if I could fetch the output of the binary.

I have not used it, but from the API description it seems that 
g_spawn_async_with_pipes() is exactly what you want.  Assuming that the 
binary is a commandline program, or otherwise outputs the information 
that you need to standard out.

Yes the binary is a commandline and I wonder how I can fetc hthe output
if there is a progress bar in text (cdparanoia for instance).

You will want to use the GLib IO monitoring on the descriptor that you 
get for the spawned binary's stdout, and then your callback will get 
called whenever there is output to be read.

Of course, if you are writing the binary, and the binary can BE the 
other thread, rather than BE CALLED FROM the other thread, then the 
situation is completely different.

Well, i'm not writing the binary :)
I want my app to be able to handle a lot of external binaries.
So I have to use the first solution :)

Thanks a lot for your advices !!!

Eric
-- 


Alexis Sukrieh <alexis sukria net> http://www.sukria.net
********************************************************
Debian/Linux enthusiast geek <http://www.debian.org>
Gnome2 glad user/tuner/hacker <http://www.gnome.org>
MyDynaWeb creator/developer   <http://mydynaweb.net>
********************************************************




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