Skip to main content

run_main

Function run_main 

Source
pub unsafe fn run_main(
    entry: unsafe extern "C" fn(*const XilaStartup) -> i32,
    heap: &mut Heap,
    arguments: &[&str],
    standard_input: Option<File>,
    standard_output: Option<File>,
    standard_error: Option<File>,
    home: Option<Directory>,
) -> i32
Expand description

Invoke a linked C entry on the calling stack, then close its granted streams. The process owner provides the heap and drops it after all native execution ends.

The entry gets no process capability and cannot exit early; the host state sits in this frame. A loader that starts native processes keeps the state off the stack: see HostState and crate::ProcessLaunch::run.

It is meant for tests and cannot be cancelled cleanly: the host state, and with it the head of the handle registry, live in this frame, so a coroutine dropped while the entry is suspended discards them with its stack and nothing can release what they hold.

ยงSafety

Entry must obey the startup lifetime and ownership rules, serialize object access, and never unwind. The heap must remain live until native execution has permanently ended.