Function spawn_cell_server

Source
pub fn spawn_cell_server(
    code_hash: &[u8],
    hash_type: ScriptHashType,
    argv: &[&CStr],
) -> Result<(Pipe, Pipe), IpcError>
Expand description

Spawns a new server process using the provided code hash and hash type. This function is similar to spawn_server, but it uses a specific cell identified by the code_hash and hash_type to spawn the new process. The function returns the read and write file descriptors for the parent process to communicate with the child process.

§Arguments

  • code_hash - A byte slice representing the code hash of the cell to spawn.
  • hash_type - The hash type of the cell (e.g., ScriptHashType::Type).
  • argv - A slice of C strings representing the arguments to pass to the new process.

§Returns

A Result containing a tuple of two Pipe representing the read and write file descriptors for the parent process, or an IpcError if an error occurs.

§Errors

This function returns an IpcError if any of the following syscalls fail:

  • pipe - If creating a pipe fails.
  • spawn_cell - If spawning the new process using the cell fails.

§Example

use ckb_script_ipc_common::spawn::spawn_cell_server;

let (read_pipe, write_pipe) = spawn_cell_server(
    code_hash,
    hash_type,
    &[CString::new("demo").unwrap().as_ref()],
).expect("Failed to spawn cell server");