---
name: "sd_bus_get_current_userdata"
section: "3"
platform: "linux"
package: "libsystemd-dev"
version: "257.13-1~deb13u1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/sd_bus_get_current_handler"
---

# sd\_bus\_get\_current\_userdata(3)

Query information of the callback a bus object is currently running

Part of [sd\_bus\_get\_current\_handler(3)](/sd_bus_get_current_handler/3.md).

## NAME

sd\_bus\_get\_current\_handler, sd\_bus\_get\_current\_message, sd\_bus\_get\_current\_slot, sd\_bus\_get\_current\_userdata - Query information of the callback a bus object is currently running

## SYNOPSIS

```
#include <systemd/sd-bus.h>
```

**typedef int (\*sd\_bus\_message\_handler\_t)(sd\_bus\_message \****m***, void \****userdata***, sd\_bus\_error \****ret\_error***);**

**sd\_bus\_message\_handler\_t sd\_bus\_get\_current\_handler(sd\_bus \****bus***);**

**sd\_bus\_message\* sd\_bus\_get\_current\_message(sd\_bus \****bus***);**

**sd\_bus\_slot\* sd\_bus\_get\_current\_slot(sd\_bus \****bus***);**

**void\* sd\_bus\_get\_current\_userdata(sd\_bus \****bus***);**

## DESCRIPTION

Whenever sd-bus is about to invoke a user-supplied callback function, it stores the current callback, D-Bus message, slot and userdata pointer and allows these to be queried via **sd\_bus\_get\_current\_handler()**, **sd\_bus\_get\_current\_message()**, **sd\_bus\_get\_current\_slot()** and **sd\_bus\_get\_current\_userdata()**, respectively. If *bus* cannot be resolved or if execution does not reside in a user-supplied callback of *bus*, these functions return **NULL**.

## RETURN VALUE

On success, these functions return the requested object. On failure, they return **NULL**.

## NOTES

Functions described here are available as a shared library, which can be compiled against and linked to with the **libsystemd** [**pkg-config**(1)](/pkg-config/1.md) file.

The code described here uses [**getenv**(3)](/getenv/3.md), which is declared to be not multi-thread-safe. This means that the code calling the functions described here must not call [**setenv**(3)](/setenv/3.md) from a parallel thread. It is recommended to only do calls to **setenv()** from an early phase of the program when no other threads have been started.

## HISTORY

**sd\_bus\_get\_current\_handler()**, **sd\_bus\_get\_current\_message()**, **sd\_bus\_get\_current\_slot()**, and **sd\_bus\_get\_current\_userdata()** were added in version 221.

## SEE ALSO

[**systemd**(1)](/systemd/1.md), [**sd-bus**(3)](/sd-bus/3.md)
