---
name: "xcb_shm_attach_fd"
section: "3"
platform: "linux"
package: "libxcb"
version: "1.17.0-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/xcb_shm_attach_fd"
---

# xcb\_shm\_attach\_fd(3)

Create a shared memory segment

## NAME

xcb\_shm\_attach\_fd - Create a shared memory segment

## SYNOPSIS

**#include \<xcb/shm.h\>**

### Request function

xcb\_void\_cookie\_t **xcb\_shm\_attach\_fd**(xcb\_connection\_t \**conn*, xcb\_shm\_seg\_t *shmseg*, int32\_t *shm\_fd*, uint8\_t *read\_only*);\

## REQUEST ARGUMENTS

- *conn*

  The XCB connection to X11.

- *shmseg*

  A shared memory segment ID created with xcb\_generate\_id().

- *shm\_fd*

  The file descriptor the server should mmap().

- *read\_only*

  True if the segment shall be mapped read only by the X11 server, otherwise false.

## DESCRIPTION

Create a shared memory segment.  The file descriptor will be mapped at offset zero, and the size will be obtained using fstat().  A zero size will result in a Value error.

## RETURN VALUE

Returns an *xcb\_void\_cookie\_t*. Errors (if any) have to be handled in the event loop.

If you want to handle errors directly with *xcb\_request\_check* instead, use *xcb\_shm\_attach\_fd\_checked*. See **[xcb-requests(3)](/xcb-requests/3.md)** for details.

## ERRORS

This request does never generate any errors.

## SEE ALSO

[**xcb-requests**(3)](/xcb-requests/3.md)

## AUTHOR

Generated from shm.xml. Contact xcb@lists.freedesktop.org for corrections and improvements.
