Skip to main content

write_record

Function write_record 

Source
pub fn write_record(
    tgid: i32,
    plan: &ExecPlan,
    trapped: Option<&Trapped>,
) -> Result<(), i32>
Expand description

Writes the record the trampoline will read for process tgid.

The record is a sequence of netstrings (<length>:<bytes>,), each holding a one-byte tag and its value; text values carry their terminating NUL so the trampoline can hand them to execve in place. The first field is v2. Then either A<n> (leading arguments, the trampoline’s own argv[1..] follow) or a<n> (the complete vector), each followed by n fields tagged -; p<path> to exec; optionally e<n> and n environment entries tagged -; c<dir> to enter; s for a new session; d to die with the parent; S<program> (binary, repeatable); I<fd> and J<fd> status descriptors; W<text> lines to print; or, instead of all of the above, E<code>:<text> or O<code>:<text> to print on stderr or stdout and exit. In the guest-stub mode m<fd>, x<path>, n<name> and, for a 32-bit program, w follow v2, and an ordinary exec that keeps the caller’s argv[0] is A0 with k, so the trampoline passes on its own argument vector whole.

§Arguments

  • tgid - Process about to exec the trampoline.
  • plan - What it should exec.
  • trapped - The guest-stub mode’s additions, if in that mode.

§Errors

Errno from writing the file.