Re: Using threads ?



Le jeu 20/02/2003 à 13:35, Alexis Sukrieh a écrit :
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.

Thanks if you can give some help here :)

just run your app this way:

pthread_create(thread, NULL, yourfunct, yourdata)

yourfunction(gpointer data){

ststus = STARTED;
int exit_status;
exit_status = system(yourcommand);

status = FINISHED;

}

status should be either global or available through yourdata.
mind you system is not too reliable with glibc (it catches some signals
without passing them through to the child process)

That's it
-- 
   _ _ _
  / \ \ \
 / / \ \ \          (el greco)
 \/_ | S  \   Muy Mano,
  | \/    /         Muy Presa.
   \_  K /  http://users.aber.ac.uk/ssk01
      \  \

Attachment: signature.asc
Description: PGP signature



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