VM_MAP_INHERIT(9)

πŸ’– VM_MAP_INHERIT πŸ’–

okay so bestie, this is vm_map_inherit from section 9 of the Kernel Developer's Manual β€” the one where we tell a memory map how it should behave when somebody forks πŸ‘Άβœ¨


✨ NAME ✨

vm_map_inherit β€” set fork inheritance flags for a range within a map 🧬


🌸 SYNOPSIS 🌸

#include <sys/param.h>
#include <vm/vm.h>
#include <vm/vm_map.h>

int
vm_map_inherit(vm_map_t map, vm_offset_t start, vm_offset_t end,
    vm_inherit_t new_inheritance);

like. look at those includes. three of them. we love a well-groomed include block πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

so vm_map_inherit() takes the range from start to end inside the target map and sets its inheritance flags to whatever new_inheritance says. that's it. that's the whole job. iconic behaviour honestly πŸ‘‘

the new_inheritance flag has to be one of exactly three values, no substitutes, no vibes-based guessing:

  • VM_INHERIT_NONE
  • VM_INHERIT_COPY
  • VM_INHERIT_SHARE

and what do they do? they control how the map gets shared with child maps when the associated process calls fork. so like, when your process has a baby process, this is the setting that decides what happens to the memory. main character energy for real 🍼


πŸ”₯ IMPLEMENTATION NOTES πŸ”₯

the way that vm_map_inherit() grabs a lock on the map using vm_map_lock(9) and just... holds it for the entire duration of the function. no cap. locked in, literally and figuratively πŸ”’


πŸ’… RETURN VALUES πŸ’…

  • KERN_SUCCESS β€” returned when the inheritance flags could actually be set. slay πŸ’–
  • KERN_INVALID_ARGUMENT β€” returned when the flags you handed over were invalid. not slay. bestie why 😭

πŸŽ€ SEE ALSO πŸŽ€


πŸ‘‘ AUTHORS πŸ‘‘

this manual page was written by Bruce M Simpson <bms@spc.org>. thank you for your service king 🫑


and that's the whole page fr fr β€” now go forth and inherit responsibly πŸ§šβ€β™€οΈ

okay so this lil masterpiece came out of Debian, dated July 19, 2003, and yes it lives at VM_MAP_INHERIT(9). old but gold, we stan a vintage manpage πŸ’œπŸŒˆβ­

πŸ“¦ where this page comes from