Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 4

Qt-interest Archive, March 2002
one application per host


Message 1 in thread

Hi all,
can you tell me an easy way for checking if the application is already
started on this host? Is there any Qt machanism? (3.0)

so long

Mike


Message 2 in thread

Your question assumes a single user OS. So the answer is it depends on
the OS and QT being a GUI library will not have an mechanism to decide
that.

Regards,
Vaidhy

On Mon, Mar 11, 2002 at 02:52:31PM +0100, Stohrer, Michael wrote:
> Hi all,
> can you tell me an easy way for checking if the application is already
> started on this host? Is there any Qt machanism? (3.0)
> 
> so long
> 
> Mike
> 
> --
> List archive and information: http://qt-interest.trolltech.com
> 


Message 3 in thread

Vaidhy, Why does his question presuppose a single user OS?

In any case, Vaidhy is probably right, I haven't seen a function for detecting 
running programs in Qt.

A simple way to do this is to decide on a place on the appropriate OS for a 
lock file, and then have you program try to make one using a consistant name. 
If it can't be made because it already exists, then you print a message like 
"An instance of this program appears to be running already. If this is in 
error, remove $LOCKFILE and restart the program."

Then make sure your program removes the lockfile when it exits. A good way to 
do this is to use the atexit function, though I have no idea if that is 
portable, though I suspect it might be.

-- 
 [ signature omitted ] 

Message 4 in thread

Another technique would be to use teh Adaptive
Communication Environment (ACE
www.cs.wustl.edu/~schmidt) to implement shared memory
on the platforms that you want to support.  The
application on startup creates a shared memory region
with a specified key and then another instance looks
for that key and see if it exists.  The shared memory
region is automatically reclaimed by ACE so you don't
have to worry about locking/unlock files...where does
the file exist...etc.

ACE runs on all platforms that Qt runs on and more!

Salman

__________________________________________________
Do You Yahoo!?
Try FREE Yahoo! Mail - the world's greatest free email!
http://mail.yahoo.com/


Message 5 in thread

The reason is as follows :

1. QT is a gui toolkit.
2. GUI are used with applications, not with system daemons.
3. In a multi-user system, each user is presented with an abstraction
that acts like the entire machine.

So the question presupposes a single user OS..

However, the question is valid if the developer wants to check if the
application is running on the user space and the lock files are one
way..

A slightly more complicated OS dependent way would be to query the
process space to check if the application is already running..

Vaidhy

On Mon, Mar 11, 2002 at 02:07:42PM -0500, Hacksaw wrote:
> Vaidhy, Why does his question presuppose a single user OS?
> 
> In any case, Vaidhy is probably right, I haven't seen a function for detecting 
> running programs in Qt.
> 
> A simple way to do this is to decide on a place on the appropriate OS for a 
> lock file, and then have you program try to make one using a consistant name. 
> If it can't be made because it already exists, then you print a message like 
> "An instance of this program appears to be running already. If this is in 
> error, remove $LOCKFILE and restart the program."
> 
> Then make sure your program removes the lockfile when it exits. A good way to 
> do this is to use the atexit function, though I have no idea if that is 
> portable, though I suspect it might be.
> 
> -- 
> "Did you ever have one of those days when you called into work just to
> make sure you weren't there already?"
> http://www.hacksaw.org -- http://www.privatecircus.com -- KB1FVD
> 
> 
>