×

Discussion Board

Results 1 to 11 of 11
  1. #1
    Registered User
    Join Date
    Dec 2008
    Posts
    40

    RProcess proc.Open() not functioning...

    Hello group,

    The problem I am facing is application exits at line
    proc.Open(procName). I am trying to catch the exit status of a process from different process. I added the PowerManagement capability required by RProcess..

    RProcess proc;
    _LIT(KMatchName,"SomeProcess*");
    TFindProcess procName(KMatchName);
    TInt rc = proc.Open(procName);

    if (rc != KErrNone)
    {
    /* open failed, handle error */
    }
    But the open()does not let move forward..
    Please help...

    Regards
    Sharat

  2. #2
    Super Contributor
    Join Date
    Jul 2007
    Location
    ShenZhen, China
    Posts
    4,346

    Re: RProcess proc.Open() not functioning...

    hi, your code has a problem.
    u define procName, but not open , so it is a bad handle.
    change the code to

    Code:
    RProcess proc;
    _LIT(KMatchName,"SomeProcess*");
    TFindProcess procName(KMatchName);
    TFullName processName;
    if ( procName.Next(processName) == KErrNone )
    {
    TInt rc = proc.Open(procName);
    
    if (rc != KErrNone)
    {
    /* open failed, handle error */
    }
    }
    ----------------------------
    坚持学习, 坚持编码
    http://www.devdiv.net/
    qxiaoyuan

  3. #3
    Registered User
    Join Date
    Dec 2008
    Posts
    40

    Question Re: RProcess proc.Open() not functioning...

    Hello again,

    Fine, but cant i access existing process exit status, asynchronously?
    I followed the code provided in forum


    RProcess proc;
    User::LeaveIfError(proc.Create(MyExeFile));
    TRequestStatus istat;
    proc.Logon(istat);
    proc.Resume();

    // Thread is executing. Can add code here to run in parallel...

    // blocks here while process is running
    User::WaitForRequest(istat);

    // Process is ended, you can use proc.ExitType()
    // proc.ExitReason() and proc.ExitCategory()
    // to get information on how the process ended.


    But my question is without create(), can I check the existing process exit status whenever it exits from another process?

    I am not sure if I am doing a blunder.. But your comments and suggestions will be helpful in either case.

    Thanks,
    Sharat.

  4. #4
    Super Contributor
    Join Date
    Mar 2004
    Location
    Singapore
    Posts
    9,968

    Re: RProcess proc.Open() not functioning...

    Well actually you can just check if the application is running in delta time (let say 1/2 sec) repeatedly. In a Active Object.

  5. #5
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,674

    Re: RProcess proc.Open() not functioning...

    "Open" is a case "without Create". Have you fixed the code?

  6. #6
    Registered User
    Join Date
    Dec 2008
    Posts
    40

    Re: RProcess proc.Open() not functioning...

    Hi group,

    No wizard, I am yet unable to fix the code.

    "User::LeaveIfError(proc.Open(procName, EOwnerThread));"

    is creating problems..In debugging I found application exits at the above statement.

    I am in confusion whether it is mandatory to start the application from same process as well.. I am actually unable to go beyond open() call.

    Thanks,
    Sharat

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

    Re: RProcess proc.Open() not functioning...

    How does your current code look like?

  8. #8
    Registered User
    Join Date
    Dec 2008
    Posts
    40

    Re: RProcess proc.Open() not functioning...

    Hello again,

    Below I am sending the code snippet where i have tried for same in active object and it is functioning..(synchronously).


    TBool aFlag = EFalse;

    while( (procName.Next(processName) ) == KErrNone )
    {
    if(processName.Find(KMatchName) == KErrNone)
    {
    aFlag = ETrue;

    }
    }
    if((aFlag == EFalse) && (Autostart_flag == 1)
    {
    CApaCommandLine* cmdLine=CApaCommandLine::NewLC();
    cmdLine->SetCommandL(EApaCommandRun);
    cmdLine->SetExecutableNameL(KMatchName);
    RApaLsSession ls;
    User::LeaveIfError(ls.Connect());
    CleanupClosePushL(ls);
    // User::LeaveIfError(ls.StartApp(*cmdLine));
    TInt Err = ls.StartApp(*cmdLine);
    if(!Err)
    {
    CleanupStack::PopAndDestroy(2); // ls and cmdLine
    iTimer.After(iStatus, 10000000);
    SetActive();
    }
    else
    {
    CleanupStack::PopAndDestroy(2); // ls and cmdLine
    iTimer.After(iStatus, 10000000);
    SetActive();
    }
    }


    Autostart value is being read from a file...indicating abrupt exit...

    But I am looking out for asynchronous check by Logon() as mentioned in link ...
    http://wiki.forum.nokia.com/index.ph...ning_Processes

    So, asynchronously I am trying to handle this way but failing...

    CASE 1
    RProcess proc;
    proc.Create(_L("RedCrossGeoLoc.exe"), KNullDesC);

    proc.Logon(iStatus);
    SetActive();


    OR

    CASE 2

    TFindProcess procName(KMatchName); // In case If process is already running...
    TInt rc = proc.Open(procName);
    proc.Logon(iStatus);
    SetActive();



    In RunL()


    // Checking iStatus value; if not normal exit...then restart application...


    I am unable to proceed in proc.Open() in second case...
    I am unable to get in Logon() in first case...

    Can you help me by providing some source code or by telling where I am goin wrong in asychronous case??

    Provided both are working code with what should I go... ? Any comments on that?

    Thanks
    Sharat!!

  9. #9
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,674

    Re: RProcess proc.Open() not functioning...

    After "Logon+SetActive" do you actually start the process (Resume)? In your SDK there are example usages of RThread (like Examples\Base\IPC\Async\Fibonacci2), you have to do the same with RProcess.

  10. #10
    Registered User
    Join Date
    Dec 2008
    Posts
    40

    Re: RProcess proc.Open() not functioning...

    Hello again,

    Thanks wizard... I make it a point from now to check the examples first before posting a question!!

    The below code works...


    void StatusCheck::NotifyAppExit()
    {
    RProcess proc;
    proc.Create(_L("RedCrossGeoLoc.exe"), KNullDesC);

    proc.Logon(iStatus);
    proc.Resume();

    proc.Close();

    SetActive();
    }



    RunL()

    if (iStatus == KErrNone)
    {
    // Do NOTHING
    }
    else if (iStatus != KErrNone)
    {
    NotifyAppExit();
    }


    Now I want to confirm only one thing, I believe asynchronous wait is much more efficient than synchronous looping every interval to check for the event. Is the statement correct??

    Regards,
    Sharat!!

  11. #11
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,674

    Re: RProcess proc.Open() not functioning...

    Polling in a loop would be an absolutely wrong idea indeed. Your latest code is a nice one, feel free to use it.

Similar Threads

  1. TFindProcess and RProcess in E32Main problem
    By Yotamix in forum Symbian
    Replies: 2
    Last Post: 2008-09-10, 11:24
  2. Running RProcess in app SDK 60 2.0
    By david_lovecraft in forum Symbian
    Replies: 1
    Last Post: 2007-03-21, 12:22
  3. Replies: 8
    Last Post: 2007-02-01, 08:16
  4. RProcess Create() function error -5 Symbian OS 9.1 !
    By navjotsingh1979 in forum Symbian
    Replies: 6
    Last Post: 2006-09-28, 10:57
  5. Series 60 SDK for Linux WITH functioning emulator?
    By wille_faler in forum Symbian Tools & SDKs
    Replies: 12
    Last Post: 2004-01-30, 00:50

Posting Permissions

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