[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: Waiting for a process to terminate
From:       Thiago Macieira <thiagom () wanadoo ! fr>
Date:       2003-08-10 17:20:52
[Download RAW message or body]

[Attachment #2 (multipart/signed)]


Joao Luis Silva Assuncao wrote:
>Hello all,
>I'm using a thread (QThread) to do some heavy job that implies to execute
>multiples times another program. Since it must wait until the process ends
> to execute a new process, I think I can use the signal  processExited to
> know when the process ends, but that implies that the thread must be a
> QObject to receive the signal. I readied in QT documentation and in some
> tutorial about kde and MT that QObject derived classes should not be used
> within threads, so this idea of using signals inside threads is probably
> not a good idea. So how can I execute a process within a thread, waiting
> for it to complete but without blocking my application?

You cannot use signals accross threads. Signals are confined to the main Qt 
event thread.

I recommend that, instead, you start your process from the event thread and 
use the normal signalling mechanisms for the child process's exit. When you 
detect that it's done, you can start another. If you need a thread to process 
some data the child created, start the thread at that moment or, if it's 
already running, use QWaitCondition or QSemaphore to tell it new data is 
available.

-- 
  Thiago Macieira  -  Registered Linux user #65028
   thiagom@mail.com           
    ICQ UIN: 1967141   PGP/GPG: 0x6EF45358; fingerprint:
    E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358

[Attachment #5 (application/pgp-signature)]

>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic