Symbian
Symbian Developer Library

SYMBIAN OS V9.4

Feedback

[Index] [Previous] [Next]

#include <e32std.h>
Link against: euser.lib

Class RProcess

class RProcess : public RHandleBase;

Description

A handle to a process.

The process itself is a kernel object.

Derivation

Members

Defined in RProcess:

Inherited from RHandleBase:


Construction and destruction


RProcess()

inline RProcess();

Description

Default constructor.

The constructor exists to initialise private data within this handle; it does not create the process object.

Specifically, it sets the handle-number to the value KCurrentProcessHandle. In effect, the constructor creates a default process handle.


RProcess(TInt)

inline RProcess(TInt aHandle);

Description

Constructor taking a handle number.

Parameters

TInt aHandle

The handle number to be used to construct this RProcess handle.

[Top]


Member functions


Create(const TDesC &,const TDesC &,TOwnerType)

IMPORT_C TInt Create(const TDesC &aFileName, const TDesC &aCommand, TOwnerType aType=EOwnerProcess);

Description

Starts a new process, loading the specified executable.

The executable can be in ROM or RAM.

By default, ownership of this process handle is vested in the current process, but can be vested in the current thread by specifying EOwnerThread as the third parameter to this function.

Parameters

const TDesC16 &aFileName

A descriptor containing the full path name of the executable to be loaded. If this name has no file extension, an extension of .EXE is appended. The length of the resulting full path name must not be greater than KMaxFileName. The length of the file name itself must not be greater than KMaxProcessName. If no path is specified, the system will look in \sys\bin on all drives.

const TDesC16 &aCommand

A descriptor containing data passed as an argument to the thread function of the new process's main thread, when it is first scheduled.

TOwnerType aType

Defines the ownership of this process handle. If not specified, EOwnerProcess is the default.

Return value

TInt

KErrNone if successful, otherwise one of the other system-wide error codes.


Create(const TDesC &,const TDesC &,const TUidType &,TOwnerType)

IMPORT_C TInt Create(const TDesC &aFileName, const TDesC &aCommand, const TUidType &aUidType, TOwnerType aType=EOwnerProcess);

Description

Starts a new process, loading the specified executable which matches the specified UID type.

The executable can be in ROM or RAM.

By default, ownership of this process handle is vested in the current process, but can be vested in the current thread by specifying EOwnerThread as the fourth parameter.

Parameters

const TDesC16 &aFileName

A descriptor containing the full path name of the executable to be loaded. If this name has no file extension, an extension of .EXE is appended. The length of the resulting full path name must not be greater than KMaxFileName. The length of the file name itself must not be greater than KMaxProcessName. If no path is specified, the system will look in \sys\bin on all drives.

const TDesC16 &aCommand

A descriptor containing data passed as an argument to the thread function of the new process's main thread, when it is first scheduled.

const TUidType &aUidType

A UID type (a triplet of UIDs) which the executable must match.

TOwnerType aType

Defines the ownership of this process handle. If not specified, EOwnerProcess is the default.

Return value

TInt

KErrNone if successful, otherwise one of the other system-wide error codes.


Open(const TDesC &,TOwnerType)

IMPORT_C TInt Open(const TDesC &aName, TOwnerType aType=EOwnerProcess);

Description

Opens a handle to a specifically named process.

By default, ownership of this process handle is vested in the current process, but can be vested in the current thread by passing EOwnerThread as the second parameter to this function.

Parameters

const TDesC16 &aName

A reference to the descriptor containing the name of the process to be opened.

TOwnerType aType

An enumeration whose enumerators define the ownership of this thread handle. If not explicitly specified, EOwnerProcess is taken as default.

Return value

TInt

KErrNone, if successful, otherwise one of the other system-wide error codes.


Open(TProcessId,TOwnerType)

IMPORT_C TInt Open(TProcessId aId, TOwnerType aType=EOwnerProcess);

Description

Opens a handle to the process whose process Id matches the specified process ID.

By default, ownership of this process handle is vested in the current process, but can be vested in the current thread by passing EOwnerThread as the second parameter to this function.

Parameters

TProcessId aId

The process Id used to find the process.

TOwnerType aType

An enumeration whose enumerators define the ownership of this process handle. If not explicitly specified, EOwnerProcess is taken as default.

Return value

TInt

KErrNone, if successful, otherwise one of the other system-wide error codes.


Type()const

IMPORT_C TUidType Type() const;

Description

Gets the Uid type associated with the process.

Return value

TUidType

A reference to a TUidType object containing the process type.


Id()const

IMPORT_C TProcessId Id() const;

Description

Gets the Id of this process.

Return value

TProcessId

The Id of this process.


RenameMe(const TDesC &)

Interface status: deprecated Use User::RenameProcess() instead

static inline TInt RenameMe(const TDesC &aName);

Description

Parameters

const TDesC16 &aName

Return value

TInt


Kill(TInt)

Capability: PowerMgmt except when one of the following situations is true: 1. the process calling this function is the same as the process to be terminated. 2. the process calling this function created the process to be terminated, but has not yet resumed that process.

IMPORT_C void Kill(TInt aReason);

Description

Ends this process, and all of its threads, specifying a reason code.

This function is intended to be used if a process is exiting under normal conditions.

If the process is system permanent, the entire system is rebooted.

Parameters

TInt aReason

The reason to be associated with the ending of this process.

See also:


Terminate(TInt)

Capability: PowerMgmt except when one of the following situations is true: 1. the process calling this function is the same as the process to be terminated. 2. the process calling this function created the process to be terminated, but has not yet resumed that process.

IMPORT_C void Terminate(TInt aReason);

Description

Ends this process, and all of its threads, specifying a reason code.

This function is intended to be used if a process is exiting under abnormal conditions, for example if an error condition has been detected.

If the process is system critical or system permanent, the entire system is rebooted.

Parameters

TInt aReason

The reason to be associated with the ending of this process.

See also:


Panic(const TDesC &,TInt)

Capability: PowerMgmt except when one of the following situations is true: 1. the process calling this function is the same as the process to be terminated. 2. the process calling this function created the process to be terminated, but has not yet resumed that process.

IMPORT_C void Panic(const TDesC &aCategory, TInt aReason);

Description

Panics the process and all of its owned threads, specifying the panic category name and reason code.

The length of the category name should be no greater than 16; any name with a length greater than 16 is truncated to 16.

If the process is system critical or system permanent, the entire system is rebooted.

Parameters

const TDesC16 &aCategory

A reference to the descriptor containing the text which defines the category name for this panic.

TInt aReason

The panic number.

See also:


Resume()

IMPORT_C void Resume();

Description

Makes the first thread in the process eligible for execution.

Panic codes

KERN-EXEC

32 if the process is not yet fully loaded.

See also:


FileName()const

IMPORT_C TFileName FileName() const;

Description

Gets a copy of the full path name of the loaded executable on which this process is based.

This is the file name which is passed to the RProcess::Create(const TDesC &,const TDesC &,TOwnerType) member function of this RProcess.

Return value

TBuf

A TBuf descriptor with a defined maximum length containing the full path name of the file.

See also:


ExitType()const

IMPORT_C TExitType ExitType() const;

Description

Tests whether the process has ended and, if it has ended, return how it ended.

This information allows the caller to distinguish between normal termination and a panic.

Return value

TExitType

An enumeration whose enumerators describe how the process has ended.


ExitReason()const

IMPORT_C TInt ExitReason() const;

Description

Gets the specific reason associated with the end of this process.

The reason number together with the category name is a way of distinguishing between different causes of process termination.

If the process has panicked, this value is the panic number. If the process has ended as a result of a call to RProcess::Kill(TInt), then the value is the one supplied by RProcess::Kill(TInt).

If the process has not ended, then the returned value is zero.

Return value

TInt

The reason associated with the end of the process.

See also:


ExitCategory()const

IMPORT_C TExitCategoryName ExitCategory() const;

Description

Gets the name of the category associated with the end of the process.

The category name together with the reason number is a way of distinguishing between different causes of process termination.

If the process has panicked, the category name is the panic category name; for example, E32USER-CBase or KERN-EXEC. If the process has ended as a result of a call to RProcess::Kill(TInt), then the category name is Kill.

If the process has not ended, then the category name is empty, i.e. the length of the category name is zero.

Return value

TBuf

A descriptor with a defined maximum length containing the name of the category associated with the end of the process.

See also:


Priority()const

IMPORT_C TProcessPriority Priority() const;

Description

Gets the priority of this process.

Return value

TProcessPriority

One of the TProcessPriority enumerator values.


SetPriority(TProcessPriority)const

IMPORT_C void SetPriority(TProcessPriority aPriority) const;

Description

Sets the priority of this process to one of the values defined by theTProcessPriority enumeration. The priority can be set to one of the four values:

EPriorityLow

EPriorityBackground

EPriorityForeground

EPriorityHigh

The absolute priority of all threads owned by the process (and all threads owned by those threads etc.) are re-calculated.

Notes:

The priority values EPriorityWindowServer, EPriorityFileServer, EPriorityRealTimeServer and EPrioritySupervisor are internal to Symbian OS and any attempt to explicitly set any of these priority values causes a KERN-EXEC 14 panic to be raised.

Any attempt to set the priority of a process which is protected and is different from the process owning the thread which invokes this function, causes a KERN-EXEC 1 panic to be raised.

A process can set its own priority whether it is protected or not.

Parameters

TProcessPriority aPriority

The priority value.


JustInTime()const

IMPORT_C TBool JustInTime() const;

Description

Tests whether "Just In Time" debugging is enabled or not for this process.

Return value

TBool

True, when "Just In Time" debugging is enabled. False otherwise.

See also:


SetJustInTime(TBool)const

IMPORT_C void SetJustInTime(TBool aBoolean) const;

Description

Enables or disables "Just In Time" debugging for this process. This will only have an effect when running on the emulator.

"Just In Time" debugging catches a thread just before it executes a panic or exception routine. Capturing a thread early, before it is terminated, allows the developer to more closely inspect what went wrong, before the kernel removes the thread. In some cases, the developer can modify context, program counter, and variables to recover the thread. This is only possible on the emulator.

By default, "Just In Time" debugging is enabled.

Parameters

TBool aBoolean

ETrue, to enable just-in-time debugging. EFalse, to disable just-in-time debugging.


Logon(TRequestStatus &)const

IMPORT_C void Logon(TRequestStatus &aStatus) const;

Description

Requests notification when this process dies, normally or otherwise.

A request for notification is an asynchronous request, and completes:

A request for notification requires memory to be allocated; if this is unavailable, then the call to RProcess::Logon(TRequestStatus &)const returns, and the asynchronous request completes immediately.

Parameters

TRequestStatus &aStatus

A reference to the request status object. This contains the reason code describing the reason for the termination of the process, i.e. the value returned by a call to RProcess::ExitReason()const. Alternatively, this is set to: KErrCancel, if an outstanding request is cancelled; KErrNoMemory, if there is insufficient memory to deal with the request.

See also:


LogonCancel(TRequestStatus &)const

IMPORT_C TInt LogonCancel(TRequestStatus &aStatus) const;

Description

Cancels an outstanding request for notification of the death of this process.

A request for notification must previously have been made, otherwise the function returns KErrGeneral.

The caller passes a reference to the same request status object as was passed in the original call to RProcess::Logon(TRequestStatus &)const.

Parameters

TRequestStatus &aStatus

A reference to the same request status object used in the original call to RProcess::Logon(TRequestStatus &)const.

Return value

TInt

KErrGeneral, if there is no outstanding request; KErrNone otherwise.

See also:


GetMemoryInfo(TModuleMemoryInfo &)const

IMPORT_C TInt GetMemoryInfo(TModuleMemoryInfo &aInfo) const;

Description

Gets the size and base address of the code and various data sections of the process.

The run addresses are also returned.

Parameters

TProcessMemoryInfo &aInfo

On successful return, contains the base address and size of the sections.

Return value

TInt

KErrNone, if successful; otherwise one of the other system wide error codes.


Open(const TFindProcess &,TOwnerType)

inline TInt Open(const TFindProcess &aFind, TOwnerType aType=EOwnerProcess);

Description

Opens a handle to the process found by pattern matching a name.

ATFindProcess object is used to find all processes whose full names match a specified pattern.

By default, ownership of this process handle is vested in the current process, but can be vested in the current thread by passing EOwnerThread as the second parameter to this function.

Parameters

const TFindProcess &aFind

A reference to the TFindProcess object used to find the process.

TOwnerType aType

An enumeration whose enumerators define the ownership of this process handle. If not explicitly specified, EOwnerProcess is taken as default.

Return value

TInt

KErrNone if successful, otherwise one of the other system-wide error codes.


Rendezvous(TRequestStatus &)const

IMPORT_C void Rendezvous(TRequestStatus &aStatus) const;

Description

Creates a Rendezvous request with the process.

The request is an asynchronous request, and completes:

Note that a request requires memory to be allocated; if this is unavailable, then this call to RProcess::Rendezvous(TRequestStatus &)const returns, and the asynchronous request completes immediately.

Parameters

TRequestStatus &aStatus

A reference to the request status object. The Rendezvous completes normally when RProcess::Rendezvous(TInt) is called, and this request status object will contain this reason code. If the process exits or panics, then this is the process exit reason value, i.e. the same value returned by RProcess::ExitReason()const. Alternatively, this is set to: KErrCancel, if an outstanding request is cancelled; KErrNoMemory, if there is insufficient memory to deal with the request.

See also:


RendezvousCancel(TRequestStatus &)const

IMPORT_C TInt RendezvousCancel(TRequestStatus &aStatus) const;

Description

Cancels a previously requested Rendezvous with the process.

The request completes with the value KErrCancel (if it was still outstanding).

Parameters

TRequestStatus &aStatus

A reference to the same request status object used in the original call to Rendezvous(TRequestStatus& aStatus).

Return value

TInt

KErrGeneral, if there is no outstanding request, KErrNone otherwise.


Rendezvous(TInt)

IMPORT_C static void Rendezvous(TInt aReason);

Description

Completes all Rendezvous' with the current process.

Parameters

TInt aReason

The reason code used to complete all rendezvous requests


SecureId()const

IMPORT_C TSecureId SecureId() const;

Description

Return the Secure ID of the process.

If an intended use of this method is to check that the Secure ID is a given value, then the use of a TSecurityPolicy object should be considered. E.g. Instead of something like:

        RProcess& process;
        TInt error = process.SecureId()==KRequiredSecureId ? KErrNone : KErrPermissionDenied;

this could be used;

        RProcess& process;
        static _LIT_SECURITY_POLICY_S0(mySidPolicy, KRequiredSecureId);
        TInt error = mySidPolicy().CheckPolicy(process);

This has the benefit that the TSecurityPolicy::CheckPolicy(RProcess,const char *)const methods are configured by the system wide Platform Security configuration. I.e. are capable of emitting diagnostic messages when a check fails and/or the check can be forced to always pass.

Return value

TSecureId

The Secure ID.

See also:


VendorId()const

IMPORT_C TVendorId VendorId() const;

Description

Return the Vendor ID of the process.

If an intended use of this method is to check that the Vendor ID is a given value, then the use of a TSecurityPolicy object should be considered. E.g. Instead of something like:

        RProcess& process;
        TInt error = process.VendorId()==KRequiredVendorId ? KErrNone : KErrPermissionDenied;

this could be used;

        RProcess& process;
        static _LIT_SECURITY_POLICY_V0(myVidPolicy, KRequiredVendorId);
        TInt error = myVidPolicy().CheckPolicy(process);

This has the benefit that the TSecurityPolicy::CheckPolicy(RProcess,const char *)const methods are configured by the system wide Platform Security configuration. I.e. are capable of emitting diagnostic messages when a check fails and/or the check can be forced to always pass.

Return value

TVendorId

The Vendor ID.

See also:


HasCapability(TCapability,const char *)const

inline TBool HasCapability(TCapability aCapability, const char *aDiagnostic=0) const;

Description

Check if the process has a given capability

When a check fails the action taken is determined by the system wide Platform Security configuration. If PlatSecDiagnostics is ON, then a diagnostic message is emitted. If PlatSecEnforcement is OFF, then this function will return ETrue even though the check failed.

Parameters

TCapability aCapability

The capability to test.

const char *aDiagnostic

A string that will be emitted along with any diagnostic message that may be issued if the test finds the capability is not present. This string must be enclosed in the __PLATSEC_DIAGNOSTIC_STRING macro which enables it to be easily removed from the system.

Return value

TBool

ETrue if the process has the capability, EFalse otherwise.


HasCapability(TCapability,TCapability,const char *)const

inline TBool HasCapability(TCapability aCapability1, TCapability aCapability2, const char *aDiagnostic=0) const;

Description

Check if the process has both of the given capabilities

When a check fails the action taken is determined by the system wide Platform Security configuration. If PlatSecDiagnostics is ON, then a diagnostic message is emitted. If PlatSecEnforcement is OFF, then this function will return ETrue even though the check failed.

Parameters

TCapability aCapability1

The first capability to test.

TCapability aCapability2

The second capability to test.

const char *aDiagnostic

A string that will be emitted along with any diagnostic message that may be issued if the test finds a capability is not present. This string must be enclosed in the __PLATSEC_DIAGNOSTIC_STRING macro which enables it to be easily removed from the system.

Return value

TBool

ETrue if the process has both the capabilities, EFalse otherwise.


SetParameter(TInt,RHandleBase)

IMPORT_C TInt SetParameter(TInt aIndex, RHandleBase aHandle);

Description

Sets the specified handle into the specified environment data slot for this process.

Parameters

TInt aIndex

An index that identifies the environment data slot. This is a value relative to zero; i.e. 0 is the first item/slot. This can range from 0 to 15.

RHandleBase aHandle

The handle to be passed to this process.

Return value

TInt

KErrNone, always.

Panic codes

KERN-EXEC

46 if this function is called by a thread running in a process that is not the creator of this process, or the handle is not local.

KERN-EXEC

51 if aSlot is negative or is greater than or equal to the value of KArgIndex.

KERN-EXEC

52 if the specified slot is already in use.


SetParameter(TInt,const RSubSessionBase &)

IMPORT_C TInt SetParameter(TInt aSlot, const RSubSessionBase &aSession);

Description

Sets the specfied sub-session into the specified environment data slot for this process.

Parameters

TInt aSlot

An index that identifies the environment data slot. This is a value relative to zero; i.e. 0 is the first item/slot. This can range from 0 to 15.

const RSubSessionBase &aSession

The sub-session.

Return value

TInt

KErrNone, if successful, otherwise one of the other system wide error codes.

Panic codes

KERN-EXEC

46 if this function is called by a thread running in a process that is not the creator of this process.

KERN-EXEC

51 if aSlot is negative or is greater than or equal to the value of KArgIndex.

KERN-EXEC

52 if the specified slot is already in use.

KERN-EXEC

53 if the length of data passed is negative.


SetParameter(TInt,const TDesC16 &)

IMPORT_C TInt SetParameter(TInt aSlot, const TDesC16 &aDes);

Description

Sets the specified 16-bit descriptor data into the specified environment data slot for this process.

Parameters

TInt aSlot

An index that identifies the environment data slot. This is a value relative to zero; i.e. 0 is the first item/slot. This can range from 0 to 15.

const TDesC16 &aDes

The 16-bit descriptor containing data be passed to this process.

Return value

TInt

KErrNone, if successful, otherwise one of the other system wide error codes.

Panic codes

KERN-EXEC

46 if this function is called by a thread running in a process that is not the creator of this process.

KERN-EXEC

51 if aSlot is negative or is greater than or equal to the value of KArgIndex.

KERN-EXEC

52 if the specified slot is already in use.

KERN-EXEC

53 if the length of data passed is negative.


SetParameter(TInt,const TDesC8 &)

IMPORT_C TInt SetParameter(TInt aSlot, const TDesC8 &aDes);

Description

Sets the specified 8-bit descriptor data into the specified environment data slot for this process.

Parameters

TInt aSlot

An index that identifies the environment data slot. This is a value relative to zero; i.e. 0 is the first item/slot. This can range from 0 to 15.

const TDesC8 &aDes

The 8-bit descriptor containing data be passed to this process.

Return value

TInt

KErrNone, if successful, otherwise one of the other system wide error codes.

Panic codes

KERN-EXEC

46 if this function is called by a thread running in a process that is not the creator of this process.

KERN-EXEC

51 if aSlot is negative or is greater than or equal to the value of KArgIndex.

KERN-EXEC

52 if the specified slot is already in use.

KERN-EXEC

53 if the length of data passed is negative.


SetParameter(TInt,TInt)

IMPORT_C TInt SetParameter(TInt aSlot, TInt aData);

Description

Sets the specfied integer value into the specified environment data slot for this process.

Parameters

TInt aSlot

An index that identifies the environment data slot. This is a value relative to zero; i.e. 0 is the first item/slot. This can range from 0 to 15.

TInt aData

The integer value.

Return value

TInt

KErrNone, if successful, otherwise one of the other system wide error codes.

Panic codes

KERN-EXEC

46 if this function is called by a thread running in a process that is not the creator of this process.

KERN-EXEC

51 if aSlot is negative or is greater than or equal to the value of KArgIndex.

KERN-EXEC

52 if the specified slot is already in use.

KERN-EXEC

53 if the length of data passed is negative.


Identity()const

Interface status: deprecated Use RProcess::SecureId() instead

inline TUid Identity() const;

Description

Return value

TUid


CreateWithStackOverride(const TDesC &,const TDesC &,const TUidType &,TInt,TOwnerType)

IMPORT_C TInt CreateWithStackOverride(const TDesC &aFileName, const TDesC &aCommand, const TUidType &aUidType, TInt aMinStackSize, TOwnerType aType);

Description

CR0885

Parameters

const TDesC16 &aFileName

const TDesC16 &aCommand

const TUidType &aUidType

TInt aMinStackSize

TOwnerType aType

Return value

TInt