pub struct Process { /* private fields */ }
Expand description

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 last thread is terminated or exits
  • the process calls Process::exit()
  • the parent job terminates the process
  • the parent job is destroyed

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

Create a new process in the job.

Create a new process with extension info.

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.put_context(cx);
})).unwrap();

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

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

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.

Get process status.

Get process exit code if it exited, else returns None.

Get the extension.

Get the VmAddressRegion of the process.

Get the job of the process.

Add a handle to the process

Add all handles to the process

Remove a handle from the process

Remove all handles from the process.

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

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

Get a futex from the process

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.

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

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

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

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

Get the kernel object corresponding to this handle_value

Get the handle’s information corresponding to handle_value.

Get information of this process.

Set the debug address.

Get the debug address.

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.

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

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

Get KoIDs of Threads.

Wait for process exit and get return code.

Trait Implementations

Formats the value using the given formatter. Read more

Get object’s KoID.

Get the name of the type of the kernel object.

Get object’s name.

Set object’s name.

Get the signal status.

Assert signal.

Deassert signal.

Change signal status: first clear then set indicated bits. Read more

Add callback for signal status changes. Read more

Attempt to find a child of the object with given KoID. Read more

If the object is related to another (such as the other end of a channel, or the parent of a job), returns the KoID of that object, otherwise returns zero. Read more

Attempt to get the object’s peer. Read more

Get object’s allowed signals.

Kill the task. The task do not terminate immediately when killed. It will terminate after all its children are terminated or some cleanups are finished. Read more

Suspend the task. Currently only thread or process handles may be suspended.

Resume the task

Get the exceptionate.

Get the debug exceptionate.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Casts the value.

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Casts the value.

Casts the value.

Casts the value.

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait. Read more

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait. Read more

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s. Read more

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s. Read more

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Casts the value.

Casts the value.

Casts the value.

Casts the value.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Casts the value.

Casts the value.

Casts the value.

Casts the value.