async fn run_lifecycle_handler() -> Result<(), Error> {
    match fruntime::take_startup_handle(HandleInfo::new(HandleType::Lifecycle, 0)) {
        Some(lifecycle_handle) => {
            let x: zx::Channel = lifecycle_handle.into();
            let async_x = AsyncChannel::from(
                fasync::Channel::from_channel(x).expect("Async channel conversion failed."),
            );
            let mut req_stream = LifecycleRequestStream::from_channel(async_x);
            while let Some(request) =
                req_stream.try_next().await.expect("Failure receiving lifecycle FIDL message")
            {
                match request {
                    LifecycleRequest::Stop { control_handle: _c } => {
                        info!("Receive lifecycle request to stop.");
                        process::exit(0);
                    }
                }
            }

            // We only arrive here if the lifecycle channel closed without
            // first sending the shutdown event, which is unexpected.
            error!("Lifecycle channel closed without first sending shutdown event");
            process::abort();
        }
        None => {
            warn!("No lifecycle channel received, likely running as a v1 component.");
            Ok(())
        }
    }
}
// This lifecycle handler is required to make use of the "main_process_critical" functionality
// in Components V2. It ensures that our process exits cleanly when the system begins a shutdown.
// If the process were to exit with a non-zero exit code, the system would abruptly reboot rather
// than performing a clean shutdown.
This lifecycle handler is required to make use of the "main_process_critical" functionality
in Components V2. It ensures that our process exits cleanly when the system begins a shutdown.
If the process were to exit with a non-zero exit code, the system would abruptly reboot rather
than performing a clean shutdown.
This lifecycle handler is required to make use of the " main_process_critical " functionality in Components V2 . It ensures that our process exits cleanly when the system begins a shutdown . If the process were to exit with a non - zero exit code the system would abruptly reboot rather than performing a clean shutdown .
async fn run_lifecycle_handler() -> Result<(), Error> {
    match fruntime::take_startup_handle(HandleInfo::new(HandleType::Lifecycle, 0)) {
        Some(lifecycle_handle) => {
            let x: zx::Channel = lifecycle_handle.into();
            let async_x = AsyncChannel::from(
                fasync::Channel::from_channel(x).expect("Async channel conversion failed."),
            );
            let mut req_stream = LifecycleRequestStream::from_channel(async_x);
            while let Some(request) =
                req_stream.try_next().await.expect("Failure receiving lifecycle FIDL message")
            {
                match request {
                    LifecycleRequest::Stop { control_handle: _c } => {
                        info!("Receive lifecycle request to stop.");
                        process::exit(0);
                    }
                }
            }
            // We only arrive here if the lifecycle channel closed without
            // first sending the shutdown event, which is unexpected.
            error!("Lifecycle channel closed without first sending shutdown event");
            process::abort();
        }
        None => {
            warn!("No lifecycle channel received, likely running as a v1 component.");
            Ok(())
        }
    }
}
async fn run_lifecycle_handler ( ) -> Result < ( ) , Error > { match fruntime :: take_startup_handle ( HandleInfo :: new ( HandleType :: Lifecycle , 0 ) ) { Some ( lifecycle_handle ) => { let x : zx :: Channel = lifecycle_handle . into ( ) ; let async_x = AsyncChannel :: from ( fasync :: Channel :: from_channel ( x ) . expect ( " " ) , ) ; let mut req_stream = LifecycleRequestStream :: from_channel ( async_x ) ; while let Some ( request ) = req_stream . try_next ( ) . await . expect ( " " ) { match request { LifecycleRequest :: Stop { control_handle : _c } => { info ! ( " " ) ; process :: exit ( 0 ) ; } } } // We only arrive here if the lifecycle channel closed without // first sending the shutdown event, which is unexpected. error ! ( " " ) ; process :: abort ( ) ; } None => { warn ! ( " " ) ; Ok ( ( ) ) } } }
This lifecycle handler is required to make use of the "main_process_critical" functionality
in Components V2.
This lifecycle handler is required to make use of the " main_process_critical " functionality in Components V2 .