TBool CLbsRootApiTest22Step::CheckProcessIsRunning(const TDesC& aProcessNamePattern)
	{
	TInt err = KErrNone;
	RProcess process;
	TFullName fullName;
	TFindProcess findProcess;
	TBool runningInstanceFound = EFalse;
	
	findProcess.Find(aProcessNamePattern);
	while (err = findProcess.Next(fullName), err == KErrNone)
		{
		TInt processOpenErr = process.Open(findProcess);
		if (processOpenErr == KErrNone)
			{
			TExitType exitType = process.ExitType();
			if (exitType == EExitPending)
				{
				// found a running instance of the process,
				// so assume everything is ok; return ETrue
				runningInstanceFound = ETrue;
				process.Close();
				break;
				}
			}
			process.Close();
		}
	
	return runningInstanceFound;	
	}
/**
Helper function to find and kill the specified process
*/
TInt CCmdTestSsmCommand::FindAndKill(const TDesC& aProcessName)
	{
	TFullName searchTerm(aProcessName);
	StripExtension( searchTerm );	
	searchTerm += _L("*");
	TFindProcess find(searchTerm);
	TFullName name;
	TInt instancesFound = 0;
	while(find.Next(name) == KErrNone)
		{
		RProcess process;
		const TInt err = process.Open(find);

		if (KErrNone == err)
			{
			if (process.ExitType() == EExitPending)
				{
				instancesFound++;
				process.Kill(KErrCancel);
				process.Close();
				INFO_PRINTF2(_L("Process %S found and killed"), &aProcessName);
				}
			process.Close();
			}
		}
	return instancesFound;
	}
void CLbsRootApiTest17Step::FinishLbsTestStep(TRequestStatus& aStatus,TBool& aFinished)
    {    	    
        RProcess nrh;
        RProcess agps;
        RProcess ng;
        TInt err;
        err = nrh.Open(KNrhProcessName);
        if(err)
            {
		    SetTestStepResult(EFail);
            }
        err = agps.Open(KAgpsProcessName);
        if(err)
            {
		    SetTestStepResult(EFail);
		    nrh.Close();
            }
        err = ng.Open(KNgProcessName);
        if(err)
            {
		    SetTestStepResult(EFail);
		    nrh.Close();
		    agps.Close();
            }

	    INFO_PRINTF1(_L("CLbsRootApiTest17Step : RequestSystemCloseDown"));
        iLbsRootProcessApi.RequestSystemCloseDown(aStatus);
    aFinished = ETrue;
    }
void CLbsRootApiTest2Step::CheckProcessesAreUp()
	{
	RProcess process;
	TInt err = process.Open(KNrhProcessName);
	if(err)
		{
		INFO_PRINTF1(_L("CLbsRootApiTest2Step : ***ERROR - NRH not found"));
		SetTestStepResult(EFail);
		}
	process.Close();
    err = process.Open(KAgpsProcessName);
    if(err)
        {
        INFO_PRINTF1(_L("CLbsRootApiTest2Step : ***ERROR - GPS LOC Manager not found"));
		SetTestStepResult(EFail);
        }
	process.Close();
    err = process.Open(KNgProcessName);
    if(err)
        {
	    INFO_PRINTF1(_L("CLbsRootApiTest2Step : ***ERROR - Network Gateway not found"));
		SetTestStepResult(EFail);
        }
	process.Close();	
	}
//------------------------------------------------------------
// RCntParserServer::Connect()
//------------------------------------------------------------
EXPORT_C TInt RCntParserServer::Connect()
	{
	LOGGER_ENTERFN( "RCntParserServer::Connect()" );

	TInt r = KErrNone;

	if( iConnected == ECntParserNotConnected )
		{
		r = CreateSession( KCntParserName, Version(), KDefaultMessageSlots );
		if(r==KErrNone) 
			{
			iConnected=ECntParserConnected;	
			}
		else
			{
			RProcess p;
			TInt err = p.Create(KTxtServer, KNullDesC);
	   		if ( err != KErrNone )
           		{
           		// Loading failed.
           		return err;
           		}
			TRequestStatus status;
			p.Rendezvous( status );
			if( status != KRequestPending )
				{
				p.Kill(0);		// abort startup
				p.Close();
				return KErrGeneral;   // status can be KErrNone: don't return status.Int()
				}
			else
				{
				p.Resume();	// logon OK - start the server
				}
			
			User::WaitForRequest( status );

			if( status != KErrNone )
				{
				p.Close();
				return status.Int();
				}

			r = CreateSession( KCntParserName, Version() );
			if( r == KErrNone )
				{
				iConnected = ECntParserConnected;	
				}
			p.Close();
			}
		}
	else
		{
		r = KErrCouldNotConnect;
		}
	LOGGER_WRITE_1( "RCntParserServer::Connect() : return %d", r );
	return r; 
	}
Exemplo n.º 6
0
TBool IsProcessRunning(const TDesC& aProcessName)
	{
	TFullName name;
	TBool IsProcessRunning(EFalse);
	TBuf<64> pattern(aProcessName);
	TInt length = pattern.Length();
	pattern += _L("*");
	TFindProcess procFinder(pattern);

	while(procFinder.Next(name) == KErrNone)
		{
		if(name.Length() > length)
			{//If found name is a string containing aProcessName string.
			TChar c(name[length]);
			if(c.IsAlphaDigit() || c == TChar('_') || c == TChar('-'))
				{//If the found name is other valid application name starting with aProcessName string.
				RDebug::Print(_L(":: Process name: \"%S\".\n"), &name);
				continue;
				}
			}
		RProcess proc;
		if(proc.Open(name) == KErrNone)
			{
			if (EExitKill == proc.ExitType())
			    {
			    RDebug::Print(_L("\"%S\" process killed.\n"), &name);
			    proc.Close();
			    IsProcessRunning = EFalse;
			    }
			 else
			    {
			    IsProcessRunning = ETrue;
			    RDebug::Print(_L("\"%S\" process is running.\n"), &name);
			    }

			if(IsProcessRunning)
				{
				RDebug::Print(_L("Waiting additional time...\n"), &name);

				User::After(1000000);

				if (EExitKill == proc.ExitType())
					{
					RDebug::Print(_L("\"%S\" process now killed.\n"), &name);
			    	IsProcessRunning = EFalse;
					}

				proc.Close();
				}
			}


		}
	return IsProcessRunning;
	}
Exemplo n.º 7
0
// ---------------------------------------------------------
// RLbtServer::Connect
//
// (other items were commented in a header).
// ---------------------------------------------------------
//
EXPORT_C TInt RLbtServer::Connect()
	{
 	__ASSERT_ALWAYS(Handle() == 0, User::Panic(KLbtClientPanicCategory, ELbtServerHandleNotClosed));
	
	TRAPD(ret, ConstructL());

	if (ret == KErrNone)
		{
		ret = CreateSession(KLbtServerCoreName, Version(), KDefaultMessageSlots);
		
		if( ret == KErrNotFound )
		    {
		    RProcess lbtServer;
		    ret = lbtServer.Create(KServerCoreProcessName, KNullDesC);
		    
		    if( ret != KErrNone )
		        {
		        lbtServer.Close();
		        return ret;
		        }
		    
		    TRequestStatus status;
		    lbtServer.Rendezvous(status);
		    
		    if( status != KRequestPending )
		        {
		        User::WaitForRequest(status);
		        lbtServer.Kill(KErrNone);
		        lbtServer.Close();
		        return KErrNotFound;
		        }
		    else
		        {
		        lbtServer.Resume();		        
		        }

		    User::WaitForRequest(status);
		    lbtServer.Close();
		    ret = status.Int();

		    if( !( ret == KErrNone || ret == KErrAlreadyExists ) )
		        {
		        return ret;
		        }

		    ret = CreateSession(KLbtServerCoreName, Version(), KDefaultMessageSlots);		    
		    }
        }
	return ret;
    }
static TInt StartDummyServer()
	{
	const TUidType serverUid(KNullUid, TUid::Uid(KSendAsServerExeUid));
	TRequestStatus started( KRequestPending );
	RProcess server;
	TInt err = server.Create(KDummyServerExe, KNullDesC(), serverUid);

	if( err != KErrNone )
		{
		return err;
		}
	
	TRequestStatus status;
	server.Rendezvous(status);
	if( status != KRequestPending )
		{
		server.Kill(0); // abort start-up
		}
	else
		{
		server.Resume();	// wait for server start-up.
		}
	User::WaitForRequest(status);
	err = (server.ExitType() == EExitPanic ) ? KErrGeneral : status.Int();
	server.Close();
	return err;	
	}
//
// Starts the IntegrityServices Server in a new process
//
static TInt StartIntegrityServicesServer()
	{
	const TUidType serverUid(KExecutableImageUid, KNullUid, KIntegrityServicesServerUid3);
	RProcess server;
	TInt err = server.Create(KIntegrityServicesServerImage, KNullDesC);

	if (err != KErrNone)
		{
		return err;
		}

	TRequestStatus stat;
	server.Rendezvous(stat);

	if (stat != KRequestPending)
		{
		server.Kill(0); // abort startup
		}
	else
		{
		server.Resume(); // logon OK, start the server
		}

	User::WaitForRequest(stat); // wait for start or death
	// We can't use the 'exit reason' if the server panicked as this is the
	// panic 'reason' and may be 0 which cannot be distinguished from KErrNone.
	err = (server.ExitType() == EExitPanic) ? KErrGeneral : stat.Int();
	server.Close();
	return err;
	}
Exemplo n.º 10
0
TInt CCapabilityTestStep::StartServer()
{
	TInt err =  KErrNone ;
	// EKA2 is simple No path required
	TBuf<32> serverFile;
	serverFile.Copy(_L("C32start"));
	//serverFile.Copy(_L("PARAM_SVR_SUITENAME"));

	_LIT(KExe,".exe");
	serverFile.Append(KExe);
	RProcess server;
	err = server.Create(serverFile,_L(""));
	if(err != KErrNone)
		return err;
	// Synchronise with the server
	TRequestStatus reqStatus;
	server.Rendezvous(reqStatus);
	server.Resume();
	 //Server will call the reciprocal static synchronise call
	User::WaitForRequest(reqStatus);
	//server.Close();
	if(reqStatus.Int() != KErrNone)
		return reqStatus.Int();
	server.Close();
	return err;
}
Exemplo n.º 11
0
//______________________________________________________________________________
//						RConsoleProxy
static TInt StartServer(const TDesC& aServerName, const TDesC& aServerArgs)
	{
	TPtrC processName(aServerName);
	if (processName.Length() && processName[0] == '!')
		{
		processName.Set(processName.Mid(1));
		}
	RProcess server;
	TInt r = server.Create(processName, aServerArgs);
	if (r!=KErrNone) return r;
	TRequestStatus stat;
	server.Rendezvous(stat);
	if (stat != KRequestPending)
		{
		server.Kill(0);
		}
	else
		{
		server.Resume();
		}
	User::WaitForRequest(stat);		// wait for start or death
	r = (server.ExitType() == EExitPanic) ? KErrGeneral : stat.Int();
	server.Close();
	return r;
	}
Exemplo n.º 12
0
void QSfwTestUtil::removeDatabases_symbian()
{
#if defined(__WINS__) && !defined(SYMBIAN_EMULATOR_SUPPORTS_PERPROCESS_WSD)
    QDir dir("C:/Data/temp/QtServiceFW");
#else
    TFindServer findServer(_L("!qsfwdatabasemanagerserver"));
    TFullName name;
    if (findServer.Next(name) == KErrNone)
    {
        RProcess dbServer;
        if (dbServer.Open(_L("qsfwdatabasemanagerserver")) == KErrNone)
        {
            dbServer.Kill(KErrNone);
            dbServer.Close();    
        }
    }    

    QDir dir("c:/private/2002AC7F");
#endif

    QString qtVersion(qVersion());
    qtVersion = qtVersion.left(qtVersion.size() - 2); //strip off patch version
    QString dbIdentifier = "_system";
    QString dbName = QString("QtServiceFramework_") + qtVersion + dbIdentifier + QLatin1String(".db");
    QFile::remove(QDir::toNativeSeparators(dir.path() + QDir::separator() + dbName));
}
Exemplo n.º 13
0
void CWsTop::SessionExited(CWsClient *aClient)
	{
	if (iShuttingDown)
		{
		RProcess proc;
		TInt err=aClient->Client().Process(proc);
		if (err==KErrNone && proc.Id()!=RProcess().Id())
			proc.Kill(0);
		else
			const_cast<RThread&>(aClient->Client()).Kill(0);
		if (err==KErrNone)
			proc.Close();
		}
	else if (iHeapCheckMode!=EWsCheckHeapOnDisconnectModeNone && aClient==iTriggerHeapCheckOnClientExit)
		{
		if (iHeapCheckMode==EWsCheckHeapOnDisconnectModeOnce)
			{
			iHeapCheckMode=EWsCheckHeapOnDisconnectModeNone;
			}
		iTriggerHeapCheckOnClientExit=NULL;
		iDoHeapCheckAndRestart=ETrue;
		Exit();
		}
	if (iServer->SessionCount()==1 && iShellBootMode==EShellBootModeNoReboot && iShell==NULL)
		StartShell();
	}
Exemplo n.º 14
0
TInt StartServer()
    {
        TRACE_STATIC_FUNC
    const TUid KKBTHIDSrvUid3 =
        {
        BTHID_SRV_UID
        };
    const TUidType serverUid(KNullUid,KNullUid, KKBTHIDSrvUid3);
    RProcess server;
    TInt r = server.Create(KBTHidServerFilename, KNullDesC, serverUid);
    if (r != KErrNone)
        return r;
    server.SetPriority(EPriorityHigh);

    TRequestStatus stat;
    server.Rendezvous(stat);
    if (stat != KRequestPending)
        {
        server.Kill(0);
        }
    else
        {
        server.Resume();
        }

    User::WaitForRequest(stat);
        TRACE_INFO((_L("[BTHID] Server started, code %d"), stat.Int()))
    r = (server.ExitType() == EExitPanic) ? KErrGeneral : stat.Int();
    server.Close();
    return r;
    }
Exemplo n.º 15
0
/**
  Start the server process. Simultaneous launching of two such processes should be detected when the second one attempts to
  create the server object, failing with KErrAlreadyExists.
*/
static TInt StartServer()
	{
	const TUidType serverUid(KNullUid,KNullUid,KServerUid3);
	RProcess server;
	TInt r = server.Create(KTestServerImg,KNullDesC,serverUid);
	if (r!=KErrNone)
		{
		return r;
		}
	
	TRequestStatus stat;
	server.Rendezvous(stat);
	if (stat!=KRequestPending)
		{
		server.Kill(0);
		}
	else
		{
		server.Resume();
		}

	// wait for start or death
	User::WaitForRequest(stat);	
	server.Close();
	
	return stat.Int();
	}
Exemplo n.º 16
0
/**
 Start a test application asynchronously using wait-for-start.
 A timeout is specified in order to instantiate the CTimeoutWaiter class
*/
void CSsTestStepAppStart::DoTestWaitForStartSyncL()
{
    INFO_PRINTF1( _L("\n\nPerforming App-start Wait-for-start sync test") );

    CSsmStartupProperties* startupProperties = CSsmStartupProperties::NewL();
    CleanupStack::PushL( startupProperties );

    startupProperties->SetFileParamsL( KTestAppGood, KNullDesC );
    startupProperties->SetCommandTypeL( ESsmCmdStartApp );
    startupProperties->SetExecutionBehaviour( ESsmWaitForSignal );
    startupProperties->SetRetries( 3 );
    startupProperties->SetTimeout( KSsTestAppStartTimeout );

    RProcess process;

    CSsmStartSafe* ss  = CSsmStartSafe::NewLC();

    CTestAndStopper* testAndStopper = new(ELeave) CTestAndStopper( *ss, *startupProperties, process, KFireAndForgetTimeout, this );
    CleanupStack::PushL( testAndStopper );
    CActiveScheduler::Start();

    process.Close();

    CleanupStack::PopAndDestroy( 3, startupProperties );

    TEST( 1 == FindAndKill(KTestAppGood) );
}
Exemplo n.º 17
0
// -----------------------------------------------------------------------------
// StartServer
// Static function to start the server process thread.
// Start the server process/thread which lives in an EPOCEXE object.
// Returns: TInt: KErrNone (0) if no error
// -----------------------------------------------------------------------------
//
static TInt StartServer()
    {
    const TUidType serverUid(KNullUid, KNullUid, KVoIPServerUid3);

    // Only one instance of the server is allowed. Attempt of launching
    // second instance of the server will fail with KErrAlreadyExists.
    RProcess server;
    TInt r = server.Create(KVoIPServerName, KNullDesC, serverUid);

    if (r != KErrNone)
        {
        return r;
        }

    TRequestStatus stat;
    server.Rendezvous(stat);

    if (stat != KRequestPending)
        {
        server.Kill(0); // abort startup
        }
    else
        {
        server.Resume(); // logon OK - start the server
        }

    User::WaitForRequest(stat); // wait for start or death

    // Panic reason cannot be '0' as it would conflict with KErrNone
    r = (server.ExitType() == EExitPanic) ? KErrGeneral : stat.Int();
    server.Close();
    return r;
    }
Exemplo n.º 18
0
void HandleStart()
{
	RDebug::Print(_L("TrkLauncher::HandleStart()"));
	
	if (!IsAlreadyRunning())
	{		
		TInt result;		
		RProcess p;
		
		//start TrkConsole	process
		result = p.Create(KTrkConsoleExe, TPtr(NULL, 0), TUidType(KNullUid, KNullUid, KTrkConsoleExeUid));
		if (result == KErrNone)
		{
			RDebug::Print(_L("TrkLauncher - Trk process resume"));
			p.Resume();
			RDebug::Print(_L("TrkLauncher - After Trk process resume"));
			p.Close();
			RDebug::Print(_L("TrkLauncher - After Trk process close"));
		}
		else
		{
			RDebug::Print(_L("TrkLauncher - Trk process not created with %d \n"),result);
			RDebug::Print(_L("TrkLauncher - Returning without process creation"));
		}
			
	}
}
Exemplo n.º 19
0
// ---------------------------------------------------------------------------
// start btnotif server from client.
// ---------------------------------------------------------------------------
//
TInt StartBTNotifSrv()
    {
    const TUidType serverUid( KNullUid, KNullUid, KBTNotifServerUid3 );
        // Create a new server process. Simultaneous launching of two processes 
        // should be detected when the second one attempts to create the server 
        // object, failing with KErrAlreadyExists.
    RProcess server;
    TInt err = server.Create( KBTNotifServerName, KNullDesC, serverUid );
    if( err != KErrNone )
        {
        return err;
        }
    TRequestStatus status;
    server.Rendezvous( status );
    if( status != KRequestPending )
        {
        server.Kill( KErrCancel );  // Abort startup
        }
    else
        {
        server.Resume();
        }
    User::WaitForRequest( status ); // Wait for start or death
    err = status.Int();
    if( server.ExitType() == EExitPanic )
        {
        // The server actually panicked; inform the client.
        err = KErrDied;
        }
    server.Close();
    return err;
    }
Exemplo n.º 20
0
void CSignalServer::RemoveSession()
	{
	iSessionCount--;

	TInt lIdx = 0;
	for(lIdx = 0; lIdx < iProcessHdlList.Count();)
		{
		TProcessId lPid(iProcessHdlList[lIdx].mPid);
		RProcess lProcHdl;
		if(lProcHdl.Open(lPid) != KErrNone)
			{
            iProcessHdlList[lIdx].mPipe.Close();
			iProcessHdlList.Remove(lIdx);
			}
		else
			{
			lProcHdl.Close();
			lIdx++;
			}
		}

	if( iSessionCount == 0 )
		{
		iShutDown->Start();
		}
	}
Exemplo n.º 21
0
TInt CSignalServer::CheckForCapability(const RMessage2& aMessage)
	{
	RThread lThread;
	RProcess lProcess;
	TInt lRetVal = KErrGeneral;

	TInt lPid = aMessage.Int0();
	TInt lSigNo = aMessage.Int1();

	if(lSigNo != SIGKILL && lSigNo != SIGSTOP)
		return KErrNone;

	lRetVal = aMessage.Client(lThread);
	if(lRetVal!= KErrNone)
		return lRetVal;
	lRetVal = lThread.Process(lProcess);
	if(lRetVal!= KErrNone)
		return lRetVal;

	if(!lProcess.HasCapability(ECapabilityPowerMgmt) && lPid!=lProcess.Id())
		lRetVal = KErrGeneral;
	else
		lRetVal = KErrNone;

	lThread.Close();
	lProcess.Close();
	return lRetVal;
	}
int InstallOperation::startJavaInstaller()
{
    JELOG2(EDebugApi);

    std::string args = java::runtime::JAVA_INSTALLER_STARTER_DLL;
    args += " poll -address=debugapi";

    std::auto_ptr<HBufC> cmdLine(stringToDes(args.c_str()));
    std::auto_ptr<HBufC> exe(stringToDes(java::runtime::JAVA_PROCESS));

    RProcess process;
    int rc = process.Create(exe->Des(), cmdLine->Des());

    if (KErrNone == rc)
    {
        // wait for JavaInstaller exit
        TRequestStatus status;
        process.Logon(status);
        process.Resume();
        User::WaitForRequest(status);
        rc = status.Int();
        process.Close();
    }

    LOG1(EDebugApi, EInfo,"javainstaller exit code: %d", rc);
    return rc;
}
Exemplo n.º 23
0
/*
-----------------------------------------------------------------------------
----------------------------------------------------------------------------
*/
TBool CTraceContainer::IsServerOn()
{
	TBool Ret(EFalse);
	
	TFileName res;
	TFindProcess find;
  	while(find.Next(res) == KErrNone)
    {
    	RProcess ph;
	  	ph.Open(res);
	  	  			
	  	if(ph.SecureId() == (TUint32)KUidTraceServerUID.iUid)
	 	{
	 		TExitType Exxit =ph.ExitType();
	 		if(Exxit == EExitPending)
	 		{
		  		Ret = ETrue;
		  		break;
	 		}
	  	}
	  	
	  	ph.Close();
    }
 
    return Ret;
}
Exemplo n.º 24
0
EXPORT_C void RPackagerTestClient::ConnectL()
/** Check and create server process if it is not already running,
then create a server session. Also constructs packager member. */
	{
	// Assume the server is already running and attempt to create a session
	// 4 message slots
	TInt err = CreateSession(KPackagerServerTestName,TVersion(1,1,1),4);
	if(err == KErrNotFound)
		{
		// Server not running
		// Use the RProcess API to start it.
		RProcess server;
		User::LeaveIfError(server.Create(KPackagerServerTestExe,KNullDesC));

		// Synchronise with the server
		TRequestStatus reqStatus;
		server.Rendezvous(reqStatus);
		// Start the test harness
		server.Resume();
		// Server will call the reciprocal static synchronise cal User::WaitForRequest(reqStatus);
		User::WaitForRequest(reqStatus);
		server.Close();
		User::LeaveIfError(reqStatus.Int() != KErrNone);
		// Create the root server session
		User::LeaveIfError(CreateSession(KPackagerServerTestName,TVersion(0,0,0),4));
		}		
		
	iPackager = CCntPackager::NewL();
	}
Exemplo n.º 25
0
// ---------------------------------------------------------------------------
// RPeninputServerImpl::StartThread
// Creates the server thread on WINS and server process on MARM.
// Access to the thread/process creation is controlled with 
// a global mutex which allows only one client thread to do
// the actual server creation in WINS. In MARM the creation of
// new server exits with KErrAlreadyExits if another thread
// already created it.
// ---------------------------------------------------------------------------
//
TInt RPeninputServerImpl::StartThreadL()
    {
    if(iWaitScheduler)
        return KErrLaunchingServer;
    TInt ret = KErrNone;

    // check if server already exists
    TFindServer findPeninputServer( KPeninputServerName );
    TFullName name;
    if (findPeninputServer.Next( name ) == KErrNone)
        {
        // if server is already running return immediately
        return KErrAlreadyExists;
        } 
    // request status which gets signaled when server has been initialized

    RProcess server;
    User::LeaveIfError(server.Create(KPeninputServerExe,KNullDesC()));
    TRequestStatus status;            
    //User::WaitForRequest(status);
    
    
    iObserver = CPeninputServerObserver::NewL(this,
                                               0);
    server.Rendezvous(iObserver->RequestStatus());
    server.Resume();
    server.Close();
                                               
    iWaitScheduler = CPeninputServerWaiter::NewL(); 
    iWaitScheduler->Start();
    ret = iWaitScheduler->Error();
    
    return ret;
    }
//This function is used in the test code to kill ECOMSERVER
//processes (or some other) when they leftover and may problem in ECOMSERVERTEST
static TInt KillProcess(const TDesC& aProcessName)
	{
	TFullName name;

	RDebug::Print(_L("Find and kill \"%S\" process.\n"), &aProcessName);

	TBuf<64> pattern(aProcessName);
	TInt length = pattern.Length();
	pattern += _L("*");
	TFindProcess procFinder(pattern);

	while(procFinder.Next(name) == KErrNone)
		{
		if(name.Length() > length) 
			{
			//If found name is a string containing aProcessName string.
			TChar c(name[length]);
			if(c.IsAlphaDigit() || c == TChar('_') || c == TChar('-'))
				{
				//If the found name is other valid application name starting with aProcessName string.
				RDebug::Print(_L(":: Process name: \"%S\".\n"), &name);
				continue;
				}
			}
		RProcess proc;
		if(proc.Open(name) == KErrNone)
			{
			proc.Kill(0);
			RDebug::Print(_L("\"%S\" process killed.\n"), &name);
			}
		proc.Close();
		}
	return KErrNone;
	}
Exemplo n.º 27
0
static void RunHelper(const TDesC& aFileToDelete, TInt aExpectedError)
/**
	Invoke the helper executable, tell it to delete the supplied file.
	
	@param	aFileToDelete	Name of file which helper executable should delete
							with RLoader::Delete.
	@param	aExpectedError	The expected return code from RLoader::Delete.
 */
	{
	TInt r;
	
	// run the helper exe, which will try to delete the file with RLoader::Delete
	RProcess ph;
	r = ph.Create(_L("tld_helper_caps.exe"), aFileToDelete);
	test(r == KErrNone);

	TRequestStatus rsh;
	ph.Logon(rsh);
	test(rsh == KRequestPending);
	ph.Resume();
	User::WaitForRequest(rsh);

	// process has died so check the panic category and reason match the expected values
	test(ph.ExitType() == EExitPanic);
	test(ph.ExitCategory() == KTldPanicCat);
	test(ph.ExitReason() == aExpectedError);

	ph.Close();
	}
Exemplo n.º 28
0
// ---------------------------------------------------------------------------
// StartServerL()  
//  Starts Fota Downlaod Interrupt Monitory server
// ---------------------------------------------------------------------------
TInt StartServerL()
    {
    FLOG(_L("StartServerLt Started"));
    TInt res = KErrNone;
    
    RProcess server;
    RSemaphore sem;
    res = sem.CreateGlobal(KFotaServerScem, EOwnerProcess);

    res=server.Create(KFotaServerName,KNullDesC);
    FLOG(_L("StartServerL-- create server error as %d"),res);
    if (res!=KErrNone)
        {       
        return res;
        }

    server.Resume();    // logon OK - start the server
    
    sem.Wait();
    sem.Close();
    server.Close();
    
    FLOG(_L("StartServerL-- server.ExitType() returns %d"),res);

    return res;
    }
/**
 * Function used by RClassControllerClient::Connect member function.
 * It exists to create a new process which contains the server side code.
 *
 * @return Value of error code created
 */
static TInt StartServer()
	{
	const TUidType serverUid(KNullUid, KNullUid, KObexCCUid);
	RProcess server;
	TInt err = server.Create(KServerExe, KNullDesC, serverUid);
	if ( err != KErrNone )
		{
		return err;
		}

	TRequestStatus stat;
	server.Rendezvous(stat);

	if ( stat != KRequestPending )
		{
		server.Kill(0); 	// abort startup
		}
	else
		{
		server.Resume();	// logon OK - start the server
		}

	User::WaitForRequest(stat); 	// wait for start or death

	// we can't use the 'exit reason' if the server paniced as this
	// is the panic 'reason' and may be '0' which cannot be distinguished
	// from KErrNone
	err = (server.ExitType() == EExitPanic) ? KErrServerTerminated : stat.Int();
	
	server.Close();

	return err;
	}
static TInt StartServer()
//
// Start the server process. Simultaneous launching
// of two such processes should be detected when the second one attempts to
// create the server object, failing with KErrAlreadyExists.
//
	{
	const TUidType serverUid(KNullUid,KNullUid,KServerUid3);
	TInt r=KErrNone;
	RProcess server;
	r=server.Create(KTestServerImg,KNullDesC,serverUid);


	if (r!=KErrNone)
		return r;
	TRequestStatus stat;
	server.Rendezvous(stat);
	if (stat!=KRequestPending)
		server.Kill(0);		// abort startup
	else
		server.Resume();	// logon OK - start the server
	User::WaitForRequest(stat);		// wait for start or death
	server.Close();
	return stat.Int();
	}