Re: Using threads ?



On 20 Feb 2003 13:35:35 +0100
Alexis Sukrieh <alexis sukria net> wrote:

Hello list :)

I'm writing a Gtk2 app that have to deal with fork/execl.
Indeed, my app should give an interface over some external binaries.

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

As far as I know, the best way here is to use threads but I really don't
know how to poroceed.

No need to use threads. Use "g_spawn_async_with_pipes". From the pipes, create
GIOchannels (with "g_io_channel_unix_new") at least for the program's stadout
and stderr. Add watches with "g_io_add_watch", and GLIB will call the
callbacks you have supplied when any data is available.

Be advised that text-mode programs sometimes use '\r' (carriage return) at the
end of a line instead of '\n" (line feed), e.g. to make a "progress bar".

Roland
-- 
R.F. Smith                           /"\    ASCII Ribbon Campaign
r s m i t h @ x s 4 a l l . n l      \ /    No HTML/RTF in email
http://www.xs4all.nl/~rsmith/         X     No Word docs in email
                                     / \    Respect for open standards

Attachment: pgpqQCIicnmDD.pgp
Description: PGP signature



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