Forum Topic - Process information from within application: (6 Items)
   
Process information from within application  
I need to be able to determine if an instance of an application is already running.  

The way I would do this on other systems is to look for the application by enumerating the running processes.

I've searched around for ways of doing this in QNX but haven't really found anything that would help.  We are using QNX 
6.3

What I would ideally like to do is as the very first line of my main, check to see if an instance of my application is 
already running and if 'Yes' then display message and abort, if 'No' continue with the execution of the application.

Thank you,
Simon Platten
Re: Process information from within application  
Hello,

Attach some name or prefix, and during the test of uniqueness try to locate that name or prefix.

Regards, PKY
Re: Process information from within application  
Thanks for the reply, but what does that mean?  Can you point me in the direction of a function to call?
Re: Process information from within application  
Hello,

have a look at this:

http://www.qnx.com/developers/docs/6.3.0SP3/neutrino/lib_ref/n/name_attach.html

In your case something like this cold suffice:

call name_open(your_name)

 if successful {
    exit // another instance already running
 } else {
    call name_attach(your_name)
    // continue with your program
 }

Regards, PKY
Re: Process information from within application  
Thank you, I will investigate.
Re: Process information from within application  
If you do not mind a system() call and interpreting the return code, you could use a 
slay -f -s0 taskName  >/dev/null
The return code will be the number of instances of taskName found.