tail_core 0.1.1

Core library for the Tail operating system
Documentation
// Copyright 2025, TAIL OS. All Rights Reserved.
//
// You must obtain a written license from and pay applicable license fees to TAIL OS
// before you may reproduce, modify, or distribute this software, or any work that
// includes all or part of this software.
//
// Free development licenses are available for evaluation, research, and non-commercial
// purposes, which may include access to the source code under these terms. Redistribution
// or commercial use without a license is strictly prohibited.
//
// This file may contain contributions from others. Please review this entire file for
// other proprietary rights or license notices, as well as the TAIL OS License Guide at
// https://tail-os.com/license-guide/ for more information.
//
// For licensing inquiries, visit https://tail-os.com or email license@tail-os.com.


use crate::service::client;
use crate::service::process_manager;
use crate::service::service_request::ServiceRequestData;
use crate::service::service_reply::ServiceReplyData;

pub fn spawn(program: &str) -> Result<i64, crate::error_kind::ErrorKind>
{
    let mut pid: u64 = 0;
    let program_bytes = program.as_bytes();

    let request_data = ServiceRequestData::new(&program_bytes[0], program.len());
    let result = client::send_service_request_and_wait_for_reply("process_manager", process_manager::PROCESS_MANAGER_SPAWN_PROCESS, &request_data);
    if result.is_err() {
        return Err(crate::error_kind::ErrorKind::from(result.err().unwrap()));
    } else {
        let reply: ServiceReplyData<i64> = result.unwrap();
        let reply_message_ref: &i64 = reply.get_reply_message_ref();
        return Ok(*reply_message_ref);
    }
}