xcb_shm_attach(3)

πŸ“¦
version 1.17.0 Β· 5 versions
, in alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, centos-stream 10, debian trixie, fedora 43, fedora 44, nixpkgs unstable, opensuse-leap 16.0, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– xcb_shm_attach β€” the xcb_shm_attach(3) page, but make it make sense

okay bestie, so this is a page from the XCB Requests corner of the libxcb universe, and today we're attaching System V shared memory segments. yes really. it's giving very "low-level but make it fashion" πŸ’…


✨ NAME ✨

xcb_shm_attach β€” attach a System V shared memory segment. that's it, that's the whole job 🫢


🌸 SYNOPSIS 🌸

first things first, you gotta let the compiler know what's up:

#include <xcb/shm.h>

πŸŽ€ Request function πŸŽ€

xcb_void_cookie_t xcb_shm_attach(xcb_connection_t *conn,
       xcb_shm_seg_t shmseg, uint32_t shmid, uint8_t read_only);

look at her. four args, one cookie, zero drama (allegedly) ✨


πŸ¦‹ REQUEST ARGUMENTS πŸ¦‹

here's who's who in this little friend group:

  • conn β€” the XCB connection to X11. your whole link to the server, your main character, your ride or die.
  • shmseg β€” a shared memory segment ID that you made with xcb_generate_id(). you gotta make it yourself, bestie, it's not gonna appear out of thin air.
  • shmid β€” the System V shared memory segment that the server should map. yes, the server maps it. that's the whole point.
  • read_only β€” True if the segment shall be mapped read only by the X11 server, otherwise false. so like, do you trust them with write access or not? πŸ‘€

πŸ’œ DESCRIPTION πŸ’œ

okay so the vibe here is: you're attaching a System V shared memory segment to the server. that's the whole plot.

heads up though β€” this will fail unless the server has permission to map the segment. no permission, no segment, no service. periodt. 😭

the cute part? the client may destroy the segment as soon as it receives a XCB_SHM_COMPLETION event with the shmseg value from this request and with the appropriate serial number. so you don't have to hover over it forever β€” once that event lands with the right serial, you're free to yeet the segment. ✨


🌈 RETURN VALUE 🌈

she returns an xcb_void_cookie_t. errors, if any, have to be handled in the event loop. that's the deal, no takebacks.

if you'd rather handle errors directly with xcb_request_check instead, use xcb_shm_attach_checked. see xcb-requests(3) for the details, iykyk.


πŸ’€ ERRORS πŸ’€

this request does never generate any errors. not one. zero. the cleanest girl in the function table, no cap. πŸ‘‘


πŸ”₯ SEE ALSO πŸ”₯


🧚 AUTHOR 🧚

Generated from shm.xml. Contact xcb@lists.freedesktop.org for corrections and improvements. (not me writing this at 2am, it's literally the manpage, go tell the mailing list bestie 🫢)


and that's the tea β˜• β€” brought to you by X Version 11, libxcb 1.17.0, and the xcb_shm_attach(3) page itself. go map something. slay πŸ’…βœ¨