×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Regular Contributor
    Join Date
    Jun 2008
    Posts
    144

    Single instance of process...

    Hi All,

    I want to keep only one instance of my process... i am checking this in same exe...

    i am using follwing code after

    __UHEAP_MARK;
    CTrapCleanup* cleanup = CTrapCleanup::New();

    in of E32Main...

    Code:
    while(find.Next(res) == KErrNone)
    	{
    		RProcess ph;
    		ph.Open(res);
     
    		#if DEBUG_MAINL
    		WRITETOLOGEX(TRACE_LEVEL_INFO, KFUNCNAME, res);
    		#endif
    		
    		if(ph.FileName().Find(_L("inboxeng")) != KErrNotFound)
    		{	
    			iProcCount++;
    
    			if (iProcCount > 1)
    			{
    			
    				ph.Close();
    
    				delete cleanup;
    	                        __UHEAP_MARKEND;
    
    	                         return KErrNone;
    			}
    		}
     
    		ph.Close();
    	}
    it comes to if (iProcCount > 1) but still i get one more instance when i see in running processes.. i am not getting what is wrong?

    Thanks & Regards,
    Sheetal.

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,671

    Re: Single instance of process...

    Are you sure about that you see running processes?

  3. #3
    Regular Contributor
    Join Date
    Jun 2008
    Posts
    144

    Re: Single instance of process...

    Quote Originally Posted by wizard_hu_ View Post
    Are you sure about that you see running processes?
    Hi,

    I am sure...
    I tried in DoStart, E32Mail.. also User::Exit(1) but it is not working...
    can process kills itself?

    Sheetal.

  4. #4
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,671

    Re: Single instance of process...

    I do not know when a process object disappear, but it may require some time. In order to find out if you really see running processes, you can check RProcess::ExitType.

  5. #5
    Regular Contributor
    Join Date
    Jun 2008
    Posts
    144

    Re: Single instance of process...

    Hi,

    I was running exe file at installation time using option FR.. when i install sis file 2nd time i dont want to start this exe since it is running already..

    Sheetal.

  6. #6
    Registered User
    Join Date
    Jan 2007
    Posts
    282

    Re: Single instance of process...

    For ensuring a single instance of a process I usually use a globally shared semaphore with a unique name.

    At app start I try to create it . If creation is successful then i am sure that there is only one instance of the process otherwise i simply exit the process. This is much simpler and safer way then iterating through all the processes in the system. Iteration through all the system process may result in two instances of the process due to race conditions and context switches. But the semaphore approach gaurantees only one instance of the process.


    Hope that helps,
    VJ

  7. #7
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,671

    Re: Single instance of process...

    Quote Originally Posted by pornima View Post
    I was running exe file at installation time using option FR.. when i install sis file 2nd time i dont want to start this exe since it is running already..
    That is really interesting. May I ask if you are actually reading what I write?

Similar Threads

  1. Replies: 2
    Last Post: 2009-03-13, 09:25
  2. how can a process detect a running instance of it
    By tal.shahar@mobile-mx.com in forum Symbian
    Replies: 1
    Last Post: 2008-06-11, 23:28
  3. Replies: 11
    Last Post: 2008-05-13, 16:36

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×