---
name: "rtapi_task_self"
section: "3rtapi"
platform: "linux"
package: "linuxcnc-uspace-dev"
version: "1:2.9.4-2+deb13u1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/rtapi_task_self"
---

# rtapi\_task\_self(3rtapi)

Retrieve ID of current task

## NAME

rtapi\_task\_self - Retrieve ID of current task

## SYNTAX

void rtapi\_task\_self()

## DESCRIPTION

**rtapi\_task\_self** retrieves the current task, or -EINVAL if not in a realtime task (e.g., in startup or shutdown code).

## REALTIME CONSIDERATIONS

May be called from init/cleanup code, and from within realtime tasks.

## RETURN VALUE

The task number previously returned by **rtapi\_task\_new** or -EINVAL.

## SEE ALSO

**[rtapi\_task\_new(3rtapi)](/rtapi_task_new/3rtapi.md)**
