Struct zircon_object::task::Process[][src]

pub struct Process { /* fields omitted */ }

Process abstraction

SYNOPSIS

A zircon process is an instance of a program in the traditional sense: a set of instructions which will be executed by one or more threads, along with a collection of resources.

DESCRIPTION

The process object is a container of the following resources:

In general, it is associated with code which it is executing until it is forcefully terminated or the program exits.

Processes are owned by jobs and allow an application that is composed by more than one process to be treated as a single entity, from the perspective of resource and permission limits, as well as lifetime control.

Lifetime

A process is created via Process::create() and its execution begins with Process::start().

The process stops execution when:

The call to Process::start() cannot be issued twice. New threads cannot be added to a process that was started and then its last thread has exited.

Implementations

impl Process[src]

pub fn create(job: &Arc<Job>, name: &str) -> ZxResult<Arc<Self>>[src]

Create a new process in the job.

pub fn create_with_ext(
    job: &Arc<Job>,
    name: &str,
    ext: impl Any + Send + Sync
) -> ZxResult<Arc<Self>>
[src]

Create a new process with extension info.

pub fn start(
    &self,
    thread: &Arc<Thread>,
    entry: usize,
    stack: usize,
    arg1: Option<Handle>,
    arg2: usize,
    thread_fn: ThreadFn
) -> ZxResult
[src]

Start the first thread in the process.

This causes a thread to begin execution at the program counter specified by entry and with the stack pointer set to stack. The arguments arg1 and arg2 are arranged to be in the architecture specific registers used for the first two arguments of a function call before the thread is started. All other registers are zero upon start.

Example

let job = Job::root();
let proc = Process::create(&job, "proc").unwrap();
let thread = Thread::create(&proc, "thread").unwrap();
let handle = Handle::new(proc.clone(), Rights::DEFAULT_PROCESS);

// start the new thread
proc.start(&thread, 1, 4, Some(handle), 2, |thread| Box::pin(async move {
    let cx = thread.wait_for_run().await;
    assert_eq!(cx.general.rip, 1);  // entry
    assert_eq!(cx.general.rsp, 4);  // stack_top
    assert_eq!(cx.general.rdi, 3);  // arg0 (handle)
    assert_eq!(cx.general.rsi, 2);  // arg1
    thread.end_running(cx);
})).unwrap();

pub fn exit(&self, retcode: i64)[src]

Exit current process with retcode. The process do not terminate immediately when exited. It will terminate after all its child threads are terminated.

pub fn check_policy(&self, condition: PolicyCondition) -> ZxResult[src]

Check whether condition is allowed in the parent job’s policy.

pub fn set_critical_at_job(
    &self,
    critical_to_job: &Arc<Job>,
    retcode_nonzero: bool
) -> ZxResult
[src]

Set a process as critical to the job.

When process terminates, job will be terminated as if task_kill() was called on it. The return code used will be ZX_TASK_RETCODE_CRITICAL_PROCESS_KILL.

The job specified must be the parent of process, or an ancestor.

If retcode_nonzero is true, then job will only be terminated if process has a non-zero return code.

pub fn status(&self) -> Status[src]

Get process status.

pub fn ext(&self) -> &Box<dyn Any + Send + Sync>[src]

Get the extension.

pub fn vmar(&self) -> Arc<VmAddressRegion>[src]

Get the VmAddressRegion of the process.

pub fn job(&self) -> Arc<Job>[src]

Get the job of the process.

pub fn add_handle(&self, handle: Handle) -> HandleValue[src]

Add a handle to the process

pub fn add_handles(&self, handles: Vec<Handle>) -> Vec<HandleValue>[src]

Add all handles to the process

pub fn remove_handle(&self, handle_value: HandleValue) -> ZxResult<Handle>[src]

Remove a handle from the process

pub fn remove_handles(
    &self,
    handle_values: &[HandleValue]
) -> ZxResult<Vec<Handle>>
[src]

Remove all handles from the process.

If one or more error happens, return one of them. All handles are discarded on success or failure.

pub fn remove_object<T: KernelObject>(
    &self,
    handle_value: HandleValue
) -> ZxResult<Arc<T>>
[src]

Remove a handle referring to a kernel object of the given type from the process.

pub fn get_futex(&self, addr: &'static AtomicI32) -> Arc<Futex>[src]

Get a futex from the process

pub fn dup_handle_operating_rights(
    &self,
    handle_value: HandleValue,
    operation: impl FnOnce(Rights) -> ZxResult<Rights>
) -> ZxResult<HandleValue>
[src]

Duplicate a handle with new rights, return the new handle value.

The handle must have Rights::DUPLICATE. To duplicate the handle with the same rights use Rights::SAME_RIGHTS. If different rights are desired they must be strictly lesser than of the source handle, or an ZxError::ACCESS_DENIED will be raised.

pub fn get_object_with_rights<T: KernelObject>(
    &self,
    handle_value: HandleValue,
    desired_rights: Rights
) -> ZxResult<Arc<T>>
[src]

Get the kernel object corresponding to this handle_value, after checking that this handle has the desired_rights.

pub fn get_object_and_rights<T: KernelObject>(
    &self,
    handle_value: HandleValue
) -> ZxResult<(Arc<T>, Rights)>
[src]

Get the kernel object corresponding to this handle_value and this handle’s rights.

pub fn get_dyn_object_with_rights(
    &self,
    handle_value: HandleValue,
    desired_rights: Rights
) -> ZxResult<Arc<dyn KernelObject>>
[src]

Get the kernel object corresponding to this handle_value, after checking that this handle has the desired_rights.

pub fn get_dyn_object_and_rights(
    &self,
    handle_value: HandleValue
) -> ZxResult<(Arc<dyn KernelObject>, Rights)>
[src]

Get the kernel object corresponding to this handle_value and this handle’s rights.

pub fn get_object<T: KernelObject>(
    &self,
    handle_value: HandleValue
) -> ZxResult<Arc<T>>
[src]

Get the kernel object corresponding to this handle_value

pub fn get_handle_info(
    &self,
    handle_value: HandleValue
) -> ZxResult<HandleBasicInfo>
[src]

Get the handle’s information corresponding to handle_value.

pub fn get_info(&self) -> ProcessInfo[src]

Get information of this process.

pub fn set_debug_addr(&self, addr: usize)[src]

Set the debug address.

pub fn get_debug_addr(&self) -> usize[src]

Get the debug address.

pub fn set_dyn_break_on_load(&self, addr: usize)[src]

Set the address where the dynamic loader will issue a debug trap on every load of a shared library to. Setting this property to zero will disable it.

pub fn get_dyn_break_on_load(&self) -> usize[src]

Get the address where the dynamic loader will issue a debug trap on every load of a shared library to.

pub fn get_cancel_token(
    &self,
    handle_value: HandleValue
) -> ZxResult<Receiver<()>>
[src]

Get an one-shot Receiver for receiving cancel message of the given handle.

pub fn thread_ids(&self) -> Vec<KoID>[src]

Get KoIDs of Threads.

pub async fn wait_for_exit(self: &Arc<Self>) -> i64[src]

Wait for process exit and get return code.

Trait Implementations

impl Debug for Process[src]

impl KernelObject for Process[src]

impl Task for Process[src]

Auto Trait Implementations

impl !RefUnwindSafe for Process

impl Send for Process

impl Sync for Process

impl Unpin for Process

impl !UnwindSafe for Process

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Downcast for T where
    T: Any
[src]

impl<T> DowncastSync for T where
    T: Send + Sync + Any
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.